Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting foobar.com and www.foobar.com to point to my Amazon S3–hosted site

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!

like image 720
bdesham Avatar asked Jun 08 '11 15:06

bdesham


2 Answers

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.

like image 91
Uriah Carpenter Avatar answered Dec 02 '22 19:12

Uriah Carpenter


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

like image 38
alexandroid Avatar answered Dec 02 '22 19:12

alexandroid