As you may already know, you can host your static website on Amazon S3, giving you the ability to sustain any conceivable level of traffic, at a very modest cost, without the need to set up, monitor, scale, or manage any web servers. With static hosting, you pay only for the storage and bandwidth that you actually consume.
S3's website hosting feature has proven to be very popular with our customers. Today we are adding two new options to give you even more control over the user experience:
- You can now host your website at the root of your domain (e.g. http://mysite.com).
- You can now use redirection rules to redirect website traffic to another domain.
Root Domain Hosting
Your website can now be accessed without specifying the “www” in the web address. Previously, you needed to use a proxy server to redirect requests for your root domain to your Amazon S3 hosted website. This introduced additional costs, extra work, and another potential point of failure. Now, you can take advantage of S3’s high availability and scalability for both “www” and root domain addresses. In order to do this, you must use Amazon Route 53 to host the DNS data for your domain.
Follow along as I set this up using the AWS Management Console:
- In the Amazon S3 Management Console, create an S3 bucket with the same name as your www subdomain, e.g. www.mysite.com. Go to the tab labeled Static Website Hosting and choose the option labeled Enable website hosting. Specify an index document (I use index.html) and upload all of your website content to this bucket.
- Create another S3 bucket with the name of the root domain, e.g. mysite.com . Go to the tab labeled Static Website Hosting, choose the option labeled Redirect all requests to another host name, and enter the bucket name from step 1:
- In the Amazon Route 53 Management Console, create two records for your domain. Create an A (alias) record in the domain's DNS hosted zone, mark it as an Alias, then choose the value that corresponds to your root domain name:
Create an Alias (A) record and set the value to the S3 website endpoint for the first bucket (the one starting with www).

Redirection Rules
We're also enhancing our website redirection functionality. You can now associate a set of redirection rules to automatically redirect requests. The rules can be used to smooth things over when you make changes to the logical structure of your site. You can also use them to switch a page or a related group of pages from static to dynamic hosting (on EC2 or elsewhere) as your site evolves and your needs change.
Amazon CTO Werner Vogels has already started using root domain support for his blog. Check out his post for more information. Our walkthrough on setting up a static website using Amazon S3, and see the Amazon S3 Developer Guide contains even more information.
If you are looking for some sites to help you build and maintain a static web site, you may enjoy Mick Gardner's recent post, An Introduction to Static Site Generators.
-- Jeff;


Just be careful here with doing CNAMEs on root domains. Things like email will break because the MX records are no longer visible behind the CNAME. Gmail for example won't send emails to domains with a CNAME as root.
Posted by: André Oppermann | December 28, 2012 at 01:19 AM
I am just wondering how many people are hosting static website nowadays?
I would be very interested if you could host asp.net websites maybe?
Windows Azure requires www. for domains and it's just too expensive for simple websites with one small DB, much more expensive than my old hosting provider.
Posted by: knockoutJs developer | December 28, 2012 at 03:41 AM
This is nice. Another welcome addition would be for S3 or CloudFront (or both) to support on the fly gzipping of content to further improve the performance of static web sites hosted on S3.
Posted by: Steve | December 28, 2012 at 04:12 AM
Nice work Jeff et al!
The main thing holding me back from hosting my site on S3 entirely is "multiviews" support -- loading myblog.com/new-blog-post instead of new-blog-post.html. I currently do that on my jekyll site wrapped in rack::rewrite on heroku with r301 %r{/(.*).html$}, '/$1'
I just glanced at the redirection docs -- doesn't look like I would be able to do this just yet?
Posted by: Paul Stamatiou | December 28, 2012 at 04:57 AM
Although that's good news in itself, it does reduce the number of buckets available by 50%.
One for www and one for root.
Are there any plans, I wonder, for increasing the number of buckets to way beyond 100?
Keith
Posted by: Keith Brook | December 28, 2012 at 05:34 AM
And what happens when someone else has already created the bucket [www.]yourdomain.com???
Posted by: James Carpenter | December 28, 2012 at 06:48 AM
Great news! Any idea if/when redirect w/ keeping query string intact will be available?
Posted by: gk | December 28, 2012 at 07:45 AM
André,
You're completely right about CNAMEs at the domain apex, they do tend to break MX and NS records. When this feature is used with Route 53 ALIAS records, no CNAME will be present - behind the scenes the ALIAS record links directly to the S3 "A" record data.
Colm
Amazon Web Services
Posted by: Colm | December 28, 2012 at 07:57 AM
Keith,
Thanks for the feedback on increasing the 100 bucket limit on S3. We will take that feedback into consideration as we think about what to do next for our customers!
Xing
Amazon Web Services
Posted by: Xing Quan | December 28, 2012 at 10:24 AM
gk,
We already support redirection while keeping the query string intact. If you follow Jeff's example in the post, he is redirecting all requests for "mysite.com" to "www.mysite.com". By default, this includes the query string that follows "mysite.com". For example, if a request is made for "mysite.com/gk", then the redirect will go to "www.mysite.com/gk".
Hope that helps.
Xing
Amazon Web Services
Posted by: Xing Quan | December 28, 2012 at 10:27 AM
Paul,
Thanks for the feedback. This is something we will keep in mind for future enhancements to static website hosting on S3.
Xing
Amazon Web Services
Posted by: Xing Quan | December 28, 2012 at 12:04 PM
The "you only have 100 buckets" problem is even worse if you have multiple hostnames that access a website; as an example, I have a set of (as yet un-launched) sites {www.,}{cydia,mobile}{,-}substrate.{com,net,org}, all of which redirect to the canonical URL; even just hosting all of these zones on Route 53 is currently irritating, but at least that is billed in a way where I can feel confident I can keep adding arbitrarily many (although at a cost that seems high, given that they are all setup identically).
To note: this is a very common use case; {www.,}microsoft.{com,net,org,co,io} all redirect to www.microsoft.com (as well as probably other suffixes I didn't test); the "all suffixes, both with and without www" redirect is probably the /most/ common case, which means that you are looking at a bucket explosion of at least 6x, not 2x, all to just get a bunch of 301 redirects. Combine this with the "bucket namespace squatting" problem, and this seems like a mis-generalization of S3 for web hosting.
However, the pricing of this service is also rather high: the 301 redirects seem to be billed at WebsiteGetObject,Requests-Tier2, which I believe (but could be wrong) is the same price as a full S3 GET request, despite seeming like it should be much easier to implement. Maybe it would be possible to at least get bulk pricing discounts on S3 requests? The cost of an S3 request is one of the few things Amazon has never decreased the price of throughout the history in their core offerings.
So, I would love to use this service (I find hosting 301 redirects for tons of websites incredibly tedious), but the economics are still better on shared hardware (as the marginal cost of serving millions of 301 redirects off EC2 is nearly 0 if you have any other servers you can toss these requests at, even though ELB and tons of redundancy) and it is not clear that the administration difficulties will actually be easier (due to the bucket explosion and possible squatting).
Posted by: Jay Freeman (saurik) | December 29, 2012 at 02:27 AM
Great, thanks! I've been waiting for this feature for a while. It would be great if you could add this for CloudFront too.
Posted by: Ben Hodgson | December 29, 2012 at 03:50 AM
Hey guys this is great, but you are still missing one key, critical need. I need for you to 302 redirect on what would otherwise be 404 errors to a URL of my choosing with the not found URL passed as a query parameter. Doing that could really open up what we could do with this static sites. Please...
Posted by: Mikeschinkel | December 29, 2012 at 05:13 AM
Would be good to address the billing issue for redirects:
Reposting from https://news.ycombinator.com/item?id=4981645:
>> These 301 redirects seem to be billed as: "WebsiteGetObject,Requests-Tier2", which I believe is $0.01 per 10,000 (not including bandwidth, and with no decrease in price for large scale). I mean, its nice that its hosted in the cloud and all, but billing at the same rate as a much more complex S3 GET request (or "GetObject,Requests-Tier2") seems much too expensive (although I can imagine that if you have only a small number of requests; if you have any other server on which you can host the 301 redirect, you can do so with a marginal cost near 0, even at a load of many millions of redirects per day.
Posted by: anon | December 31, 2012 at 12:25 AM
When I try to create a CNAME record and set the value to the S3 website endpoint for the first bucket, I get the following:
RRSet of type CNAME with DNS name mydomain.com. is not permitted at apex in zone mydomain.com.
Posted by: Casey Dexter | December 31, 2012 at 08:01 AM
Casey,
The CNAME record can be set on a subdomain of your domain, such as "www.mydomain.com" or "home.mydomain.com". CNAME records cannot be set on the zone apex, which would be "mydomain.com". In Route 53, that's what the Alias record is for; it's also the step that Jeff is showing in step 3 in this blog post.
Xing,
Amazon Web Services
Posted by: Xing Quan | December 31, 2012 at 10:20 AM
Mikeschinkel,
You can set your own redirection rule to accomplish that type of redirection. In the console, try the following XML code for your redirection rule. This will 302 redirect all 404 errors to a hostname of your choosing and keep the query string intact.
http://media.amazonwebservices.com/blog/s3_redirect_example.xml
Posted by: Xing Quan | December 31, 2012 at 12:10 PM
can you set this up as a cookie-less domain for static content similar too http://cdn.sstatic.net/ also is on a cdn ?
Posted by: Sjehutch | January 01, 2013 at 05:34 PM
So what happens when someone is "squatting" on a bucket name that matches _your_ domain name? It's already happened, see: http://threads2.scripting.com/2013/january/aFunnyThingHappened
Posted by: Adam | January 10, 2013 at 01:08 PM
(Hi Mike!)
I recently discovered that the redirect policies in the static website Routing Rules section is limited to 20 Routes. This is the only type of redirect that can handle URLs with query strings. So if I'm moving a Wordpress blog over and it had URLs of the form "host/?p=4" I could create a Route to redirect that to an Object. But you can only have 20 of those. I need about 420 of them. Anyone have any suggestions for how to deal with that?
Posted by: Michael Mealling | January 15, 2013 at 05:53 AM
Hi @Xing Quan - Thanks much for the comments. That's perfect for my needs!
@Micahel Mealling Bummer, hope they can open it up for your.
Posted by: Mike Schinkel | January 15, 2013 at 09:37 AM
Hi Xing Quan,
Thanks so much for your answer. I am trying to do what you suggest but I keep getting "NoSuchKey".
Here's a Gist showing what I am trying:
- https://gist.github.com/4540606
Posted by: Mike Schinkel | January 15, 2013 at 10:16 AM
Michael Mealling,
Thanks for your feedback on increasing the rule limit for our redirection rules feature. For your use case, you can also consider using our object-level redirect feature. You can read more about it here: http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html. You can also see Jeff's blog post on it: http://aws.typepad.com/aws/2012/10/amazon-s3-support-for-website-redirects.html
Using this method, there is no limit on the amount of redirects you can configure.
Xing,
Amazon Web Services
Posted by: Xing Quan | January 15, 2013 at 02:31 PM
I set this up successfully for a .com domain, but can't get it to work for a .io domain. Specifically, I get no host records when doing a query for it. Is there something incompatible about those .io domains?
Posted by: Luigi Montanez | January 20, 2013 at 10:25 AM