5

I have a website hosted at Amazon S3; the URL is something like www.foobar.com.s3-website-us-east-1.amazonaws.com. I would like to set my domain registrar (NameCheap) to redirect both foobar.com and www.foobar.com to this website. Setting the record

www.foobar.com CNAME www.foobar.com.s3-website-us-east-1.amazonaws.com.

works fine for the www subdomain. However, I can’t figure out how to configure the no-subdomain version of the site. I tried

foobar.com CNAME www.foobar.com.s3-website-us-east-1.amazonaws.com.

but that doesn’t seem to work. (And did I read somewhere that CNAMEs aren’t supposed to be used like this?) I know that the S3 bucket name is supposed to be identical to the fully-qualified DNS name, but does this really mean that I need to mirror my website contents in two different buckets? I feel like there must be a better solution than that.

Thanks!

bdesham
  • 15,430
  • 13
  • 79
  • 123

2 Answers2

4

You cannot serve "domain apex" content from S3-hosted websites. The easiest solution is to configure your domain such that "foobar.com" is redirected to "www.foobar.com". Unfortunately this requires you to run a HTTP server with a rewrite rule to enforce it.

I can't vouch personally for the service but http://www.wwwizer.com/ offers a free apex to www redirect service.

Uriah Carpenter
  • 6,656
  • 32
  • 28
  • This is longer accurate, although it was when it was written. This is now possible with Alias records if the domain is hosted in Route 53. – Michael - sqlbot Apr 08 '15 at 18:16
2

It looks like AWS S3 added bucket redirection around the end of 2012 to allow support for www.foobar.com and foobar.com

alexandroid
  • 1,469
  • 2
  • 15
  • 32