I'm attempting to host a static website in AWS for example.com
and www.example.com
using HTTPS. My current setup properly redirects to to example.com
but hits Chrome with a zillion 301 redirects.
The most promising info was this tutorial: Cloudfront redirect www to naked domain with ssl
and this stackoverflow answer: Cloudfront redirect www to naked domain with ssl
I have two S3 buckets. In the AWS console for S3, www.example.com
is set to redirect to example.com
via https, and example.com
is set to host a static website.
I have two Cloudfront distributions, each using an SSL certificate generated using ACM from the us-east-1 region. Origin Domain Name was set by copy / pasting the corresponding S3 endpoint URL rather than using dropdown autopopulate. Alternate Domain Name is set to the matching domain www.example.com
or example.com
for each distribution.
In Route53, I have two A records, one for each domain. Both are able to see their corresponding Cloudfront distributions populate the dropdown in the Alias menu, and have been selected.
The 301 errors seem to come from cloudfront even in the case where I access the S3 endpoints directly using the long form urls (http response in Chrome devtools has a value of X-Cache: Redirect from cloudfront
).
The website is nothing more than an index.html with some text. No javascript in play.
Any help is greatly appreciated. Burning days on this..