I'm using an Amazon S3 bucket to host my static website. Why is the bucket returning a list of objects instead of the website's index page?
Last updated: 2020-02-24
I'm using an Amazon Simple Storage Service (Amazon S3) bucket to host my static website. When I send a request to the bucket, I see an XML list of objects instead of the index page that I set up for my website. Why is this happening? How do I get Amazon S3 to return the index page?
Amazon S3 buckets have both a website endpoint and a REST API endpoint. Website endpoints use this format:
REST API endpoints use this format:
If you send a GET request to the bucket, you must send the request to the website endpoint so that Amazon S3 returns the index page (called the "index document" in the Amazon S3 console). If you send a GET request to the REST API endpoint, Amazon S3 returns a list of objects in the bucket.
If you use an Amazon CloudFront distribution with an Amazon S3 origin, you must also set the index page as the default root object to be sure that Amazon S3 returns the index page.
Important: Endpoints vary by AWS Region. For website endpoints by Region, see Amazon Simple Storage Service Website Endpoints. For REST API endpoints by Region, see AWS Regions and Endpoints - Amazon Simple Storage Service (Amazon S3).
Follow these steps to find your bucket's website endpoint:
- Open the Amazon S3 console.
- From the bucket list, choose the bucket that you're using to host the static website.
- Choose the Properties view, and then choose Static website hosting.
The website endpoint is the value that's listed as Endpoint.
If you're using a CloudFront distribution with an Amazon S3 origin, follow these steps to set your distribution's default root object to the index page:
- Open the CloudFront console.
- From the distribution list, choose the distribution associated with your S3 bucket.
- From the General view, choose Edit.
- For Default Root Object, enter the object name of your index page (for example, "index.html").
- Choose Yes, Edit.