301 Redirect Subdomain Forwarding On AWS Route 53


UPDATED: fixed missing/broken gist link with the code snippet.
UPDATE #2 May 24, 2017: updating this post since S3 has a new UI.

Recently I decided to ditch registrar DNS Managers like GoDaddy’s in favor of Amazon’s Route53. I really like their console and the DNS is snappy and responsive, not to mention the handy features when creating and pointing to Load Balancers for your TLD. However, one draw back of Route 53 is the lack of subdomain forwarding. Below is a quick solution.

All you will need is an Amazon S3 bucket, the static website end-point, and a Route 53 CNAME.

1.) Create an S3 Bucket: Name the bucket ie: subdomaintoForward.mydomain.com. It has to be the exact subdomain you wish to forward otherwise Route 53 won’t resolve. Choose the region and create!

Create An S3 Bucket

2.) Set Properties: I don’t typically Set Properties for S3 bucket forwarding, but it’s an option for your specific use case. Skip this step if you’re not familiar with this.

3.) Set Permissions: Be sure to set the group permissions under Everyone to Read. This will allow the public to access the S3 bucket contents.

4.) Enable S3 Website Hosting: Open your new bucket and click the “Properties” tab.

Open up “Static Website Hosting” than select “Use this bucket to host a website”. Make the “Index document” simply index.html. After that, you will need to copy/paste the sample JSON below into “Redirection Rules”.

IMPORTANT: Open up Notepad or SimpleEdit and make note of the ENDPOINT. This will be used in Step 5 when you point the subdomain DNS.

Be sure to read the JSON closely and edit HostName and ReplaceKeyPrefixWith values. Paste in the XML below:


view raw


hosted with ❤ by GitHub

Again, just for clarification lets breaks down the JSON above. In this example, I want subdomaintoForward.mydomain.com to 301 redirect to http://domaintoforwardto.com/anything/after/thedomain/index5.html – compare this URL to the XML above, you should be able to figure out the syntax.

Click Save!

5.) Create A CNAME in Route 53: Make note of the “Static Website Hosting” End-point, copy that, then open up Amazon Route 53. Select your Hosted Zone and click “Go to Record Sets”. Click “Create Record Set” and configure your Record. In this example, domaintoForward is the subdomain, use CNAME, and paste in the Static Web Hosting End-point into Value. Create the record.


8 thoughts on “301 Redirect Subdomain Forwarding On AWS Route 53

  1. altitude say:

    Thanks for sharing!

  2. Rich say:

    Where do I get the feature/link to create an S3 Bucket?

  3. Brent say:

    Thanks for sharing. Is there a way to have multiple rerouting rules? For instance say you want reroute:
    subdomaintoForward.mydomain.com to

    but you want to also reroute:
    subdomaintoForward.mydomain.com/something-else to

  4. jonathon schleicher say:

    good lord i could kiss you

  5. I just rewrote a portion of this tutorial since S3 has a new UI. I’m sure it confused a few people discovering this. If you have questions feel free to drop a comment.

  6. Demian say:

    Can this work also for *.something.com -> *.somethingelse.com and keeping the subdomain

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax