Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I redirect a naked (apex) domain to www using Route 53?

I need to do a 301 redirect from example.com to www.example.com using Route 53 (and S3 if necessary). There are a few solutions for similar problems but they either do not address how to redirect from the apex or they simply don't work.

When I follow the steps here, Route 53 tells me I can't add a CNAME to the apex domain. Therefore, I'm stuck in the mud.

This seems dumb simple but Amazon is making it hard. Any help would be appreciated.

enter image description here

like image 519
Barrett Kuethen Avatar asked Feb 26 '14 21:02

Barrett Kuethen


People also ask

How do I redirect a URL on Route 53?

Redirect using a Canonical Name Record (CNAME)Create a CNAME record in your Route 53 hosted zone to configure DNS redirection to map a non-apex domain to another domain. For example: www.example.com CNAME anysubdomain.example.com or www.example.net.


1 Answers

I just managed to figure this out yesterday:

  1. Go to your S3 console at https://console.aws.amazon.com/s3/home and click Create bucket. For Bucket name enter in your naked domain name, e.g. for www.example.com, you would put just example.com. Then click Create.

  2. Click on the name of the new bucket, then click Properties > Static website hosting. On the menu that appears select Redirect requests. For Target bucket or domain enter in the full domain, such as www.example.com. For Protocol put in the desired protocol, http or https. Click Save.

  3. Open your Route 53 hosted zone by navigating to https://console.aws.amazon.com/route53/home and clicking Hosted zones in the menu to the left. Select your domain and click on Create Record Set. Leave the Name area blank, and leave the default type at A - IPv4 address. Select Yes for Alias, and click on the Alias Target textbox. You may have to wait a few moments for the values in the dropdown menu that appears to populate. At this point the menu should contain the S3 Website Endpoint you created in steps 1 and 2. Select it.

Lastly, click Create, and enjoy your new routing set-up!

like image 51
omikes Avatar answered Sep 24 '22 19:09

omikes