Creating a simple Route 53 redirect with Amazon S3

Have a domain on AWS Route 53? Need it to point somewhere else? Here’s a quick and simple guide on why you might need to do that and how to do it:

Why set up a redirect?

In my case I have a couple of domains on Route 53, but this website is hosted on Squarespace. You could transfer the domains to Squarespace, but I think the hosting fees on Squarespace are higher than AWS. You can use Squarespace to redirect your domain to your website, but it won’t let you redirect to a specific page. I own onlycapys.com and I wanted it to redirect to jenaror.com/shop, so here’s how I did it.

Cost

BTW this is extremely cheap. Since we’re only using S3 for redirects, the cost should come out to $.005 per 1000 requests.

S3 Bucket configuration

First step is to head over to S3 on AWS. From there hit Create Bucket on the top left:

screenshot of S3 home

Name your bucket the exact same name as your domain. In this example, mywebsite.com

screenshot of s3 interface

croll down to Block Public Access and make sure to uncheck the top most action. Unchecking that will prompt a confirmation below that, make sure to acknowledge that and check the box. We need public access since we’ll be using this S3 bucket for redirects.

screenshot of s3 interface

Hit Create Bucket on the bottom and it’ll throw us out to our list of S3 buckets. Click on the one we just created:

screenshot of s3 buckets

Take note of the AWS region you have configured for your bucket. Click on the name on the left and you’ll be on the following screen. Click on Properties at the top:

screenshot of s3 bucket options

Scroll to the very bottom of this menu and look for Static Website Hosting. Click Edit on the left:

S3 bucket static website hosting menu

From this menu, we’ll Enable Static Website Hosting, change Hosting Type to Redirect Requests, and change the Host name to whatever website you want to redirect. Don’t worry about the protocol, since the destination will handle the http/https request. Hit Save Changes.

static website hosting menu on S3

route 53 configuration

We’re done with S3. Let’s head back to Route 53 and click our domain under Hosted Zones.

route 53 hosted zone menu

Hit Create record. If you see something different from the following screenshot, look for a menu option near the top that says Switch to quick create. On the following screen type in the following settings for your new record:

Name - blank

Record Type - A

Alias - Yes

Alias type - Alias to S3 website endpoint

From there make sure to select the same region we noted down before, and underneath that select the S3 bucket we just created:

create record menu in s3

Hit Create records and that’s it! It’ll take around 45 seconds for Route 53 to update, but once it’s done navigate over to your domain and see if it redirects!

Troubleshooting

The only troubleshooting I have is if you get a 400 Bad Gateway error when navigating to your website, make sure that you selected the same region in Route 53 as S3. I didn’t the first time and I got this error. If you made this mistake and are still getting the error, try closing your browser, it might be that it cached the bad website and it just needs to be cleared for it redirect correctly.

If you have any questions or need help, feel free to leave a comment below and I’ll see if I can’t chime in.