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?.