Menu
Amazon Simple Storage Service
Console User Guide (API Version 2006-03-01)

Configuring a Bucket for Website Hosting

You can host static websites on Amazon S3. For conceptual information, go to Hosting Websites on Amazon S3 in the Amazon Simple Storage Service Developer Guide. This section explains how to use the Amazon S3 console to configure a bucket as a website.

To manage a bucket's website configuration

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.

  2. In the Buckets pane, click the bucket that you want to configure.

  3. In the result pane, click Static Website Hosting.

  4. Do one of the following:

    • To configure a bucket for website hosting, click Enable website hosting. In the Index Document box, type the name of the index document. Optionally, in the Error Document box, you can also provide the name of a custom error document and specify custom rules to redirect requests. For more information, go to Configure a Bucket for Website Hosting in the Amazon Simple Storage Service Developer Guide.

    • To redirect all requests to a different web page, click Redirect all requests to another host name. In the Redirect all requests to box, type the name of the location where you want requests to be redirected, for example, example.com or http://example.com. If you don't specify the protocol (http, https), the protocol of the original request is used. If you redirect all requests, then any request made to the bucket's website endpoint will be redirected to the specified host name.

  5. When the settings are as you want them, click Save.

  6. Add the following policy to the bucket to grant everyone access to the objects in the bucket. For step-by-step instructions, see Editing Bucket Permissions.

    When you configure a bucket as a website, you must make the objects that you want to serve publicly readable. To do so, you write a bucket policy that grants everyone s3:GetObject permission. The following sample bucket policy grants everyone access to the objects in the example-bucket bucket.

    Copy
    { "Version":"2012-10-17", "Statement":[{ "Sid":"PublicReadGetObject", "Effect":"Allow", "Principal": "*", "Action":["s3:GetObject"], "Resource":["arn:aws:s3:::example-bucket/*" ] } ] }

    For more information, go to Permissions Required for Website Access in the Amazon Simple Storage Service Developer Guide.

Note

If you click Do not enable website hosting, Amazon S3 removes any existing website configuration from the bucket, and the bucket is not accessible from the website endpoint. However, the bucket is still available at the REST endpoint.