Reputation: 5081
I'm trying to do the following redirect on AWS:
https://www.example.com --> https://example.com
The usual approach with AWS is to set up an S3 bucket and set it to redirect, then make a record set pointing to that S3 bucket. This only works when visitors enter the non-https version of the domain. I'm trying to solve for the case where someone might go to https://www.example.com
. Currently if they go to that address it just times out.
What's the best way to do this? I've tried setting up an entire CloudFront distribution so I can set up a certificate on the www subdomain, but CloudFront doesn't recognize the redirect rules set on my S3 bucket, it just wants the files, so I'm left with feeding it a meta refresh page which is a really gnarly solution.
Upvotes: 1
Views: 976
Reputation: 179364
CloudFront doesn't recognize the redirect rules set on my S3 bucket, it just wants the files
This suggests that you pointed CloudFront to the REST endpoint of the bucket (by selecting the bucket from the drop-down list when creating the origin), which doesn't use the redirect rules. You need the web site endpoint.
Find the web site endpoint hostname for the bucket in the S3 console and paste that in as Origin Domain Name. This creates the web site endpoint as a custom origin, and the redirection configuration from the target bucket will be used.
Note
Be sure to specify the static website hosting endpoint, not the name of the bucket.
http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-cloudfront-walkthrough.html
Upvotes: 1