AWS/Route53/S3: Redirecting www.example.com to example.com works. Redirecting example.com to www.example.com doesn't

Calaf asked:

To set up a static site on S3 with DNS on Route53, we have two options.

If we want the users to type www.example.com and have that auto-replaced in the address bar by example.com, we would do the following.

  • On S3: we set two buckets, one for example.com and the other for www.example.com. We “Redirect all requests” from www.example.com to example.com while the latter has “Enable website hosting” and of course the actual files.
  • On Route53: At the hosted zone for example.com, we get two Record Sets already made: one NS and the other SOA. We set a third, an Alias Record Set with Name: example.com and set the Value to the one offered by the UI. We also set a fourth, a CNAME, with Name: www.example.com and Value: example.com.

That works!

Suppose now that we want to do the converse.

If we want the users to type example.com and have that auto-replaced in the address bar by www.example.com, I expected that the following would be the recipe.

  • On S3: we set two buckets, one for example.com and the other for www.example.com. We “Redirect all requests” from example.com to www.example.com while the latter has “Enable website hosting” as well as the actual files.
  • On Route53: At the hosted zone for example.com, we get two Record Sets already made: one NS and the other SOA. We set a third, an Alias Record Set with Name: www.example.com and set the Value to the one offered by the UI.

This doesn’t work.

What am I missing?

My answer:


You’re missing the Alias record set for example.com that points to the S3 bucket example.com which contains the redirect.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.