1
votes

We have a S3 bucket serving a static website, and it's located 'behind' a CloudFront distribution (for SSL access). It uses the www subdomain, and something like https://www.our-domain.com/ works fine.

Now we also want the 'apex' or 'naked' domain to work correctly by redirecting (via a 301 redirect) all requests to that website above. Unfortunately, that does not seem to work.

For the setup, we created another S3 bucket, something like redirect-our-domain-website, and in the properties we enabled static website hosting, selecting to redirect all requests to the target www.our-domain.com.

When we retrieve this latter bucket via the S3 bucket endpoint for static websites, http://redirect-our-domain-website.s3-website-eu-west-1.amazonaws.com we are being redirected correctly to the intended target www.our-domain.com.

Unfortunately, when creating a CloudFront distribution to also front that 'static website redirector' (again, for SSL), the redirection does not seem to get activated.

The browser result for request on the 'naked' domain https://our-domain.com/ shows that AWS S3 XML document:

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Name>redirect-our-domain-website</Name>
  <Prefix/>
  <Marker/>
  <MaxKeys>1000</MaxKeys>
  <IsTruncated>false</IsTruncated>
</ListBucketResult>

So, instead of redirecting to the intended target, it shows a ListBucketResult of the S3 bucket of the static website redirector.

I had expected that the S3 static website redirection would redirect the request to the other S3 static website (actually containing the website).

1

1 Answers

1
votes

Since no configuration details have been provided, would be difficult to identify the causes.

As there are many articles that have done the same, by comparing it will identify what is missing, or just re-using them would do the work.