Why S3 website redirect location is not followed by CloudFront?
- by ychaze
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