Why S3 website redirect location is not followed by CloudFront?

Posted by ychaze on Server Fault See other posts from Server Fault or by ychaze
Published on 2012-11-21T16:52:29Z Indexed on 2012/11/21 17:01 UTC
Read the original article Hit count: 232

I have a website hosted on Amazon S3. It is the new version of an old website hosted on WordPress.

I have set up some files with the metadata Website Redirect Locationto handle old location and redirect them to the new website pages.

For example: I had http://www.mysite.com/solution that I want to redirect to http://mysite.s3-website-us-east-1.amazonaws.com/product.html So I created an empty file named solutioninside my bucket with the correct metadata:

Website Redirect Location= /product.html

The S3 redirect metadata is equivalent to a 301 Moved Permanentlythat is great for SEO. This works great when accessing the URL directly from S3 domain.

I have also set up a CloudFront distribution based on the website bucket. And when I try to access through my distribution, the redirect does not work, ie:

http://xxxx123.cloudfront.net/solution does not redirect but download the empty file instead.

So my question is how to keep the redirection through the CloudFront distribution ? Or any idea on how to handle the redirection without deteriorate SEO ?

Thanks

© Server Fault or respective owner

Related posts about amazon-s3

Related posts about amazon-cloudfront