How to redirect domain with prefix www in AWS Route 53

mbdvg picture mbdvg · Apr 5, 2013 · Viewed 15.7k times · Source

I have a problem with domain hosting in Route 53.

I need to redirect from xyz.com to www.xyz.com, so I created a Hosted Zone on Route 53. I added an A record with the address of my ELB, and a CNAME with a name of www.xyz.com and value of my ELB address.

But this set up does not redirect my naked domain to my www prefixed domain. How do I solve this issue?

Answer

Oleg Vaskevich picture Oleg Vaskevich · Jan 16, 2014

I've gotten this to work using both S3 and CloudFront.

You need two buckets: www.yourdomainname.com and yourdomainname.com.

Keep your files in the www bucket. For the naked domain bucket properties, go to the "Static Website Hosting" section and select "redirect all requests to another host name", and enter www.yourdomainname.com.