I'm trying to setup redirect from the apex domain example.com to www.example.com with route53, cloudfront and s3.
I've seen many tutorials online and discussions here on the topic, but nothing has worked for me yet. And it's not clear exactly what records to create in route53.
Currently I have,
ALIAS A example.com www.example.com
ALIAS A www.example.com abcdefg.cloudfront.net
As recommended in this setup video tutorial and many others.
This didn't work so I also tried to add a .htaccess with the following
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
Which didn't work either.
Lots of people also suggest using a CNAME record, however it seems quite obvious to me that this doesn't work and mentioned in this answer Why can't a CNAME record be used at the apex (aka root) of a domain?.
.htaccessfile? If you are sure this is happening (e.g. by redirecting all requests) then please show your revised.htaccessfile. – tater Aug 03 '20 at 10:52.htaccessfile even gets processed or if it is completely ignored. At least previously it was not processed (see https://stackoverflow.com/questions/14095818/amazon-s3-and-htaccess). – tater Aug 03 '20 at 11:27.htaccessfile that you tested which did successfully do something? – tater Aug 13 '20 at 13:52example.com/.htaccessand downloads that file. However, the url is never redirected and stays on the apex domain. – Kaigo Aug 13 '20 at 14:08.htaccessrules should not be visible to the public. Basically my suspicion is that S3 does not process any rules in a.htaccessfile (see link in above comment) and so far there hasn't been any evidence to the contrary. If the.htaccessfile is not being processed, then it will be impossible to do such a redirect usingRewriteRule. You'd need to either give up on the redirect; see if CloudFront itself offers redirection; or move to a proper web server. – tater Aug 13 '20 at 14:19.htaccess. – tater Aug 13 '20 at 14:30