Amazon CloudFront Doesn't Respect My S3 Website Bucket's index.html Rules

Solution 1:

S3 Website features can be used in conjunction with Amazon CloudFront. However, S3 Website uses a different domain name than regular S3 buckets. In this case, you'll need to set the Origin Domain Name of your CloudFront distribution's origin configuration to new.rdegges.com.s3-website-us-east-1.amazonaws.com.

You can take this URL (Endpoint) from the Static Website Hosting panel on S3:

Static Website Hosting panel on S3

Once CloudFront is pointed to the S3 website domain name, the S3 web site features should work.

Solution 2:

I would like to add a few things to the accepted answer.

First, make sure you have a Default Root Object on your cloud front. As specified in the documentation this will not apply to subdirectories.

When setting up a new distribution of cloudfront, it will let you select your bucket bucket-name.s3.amazonaws.com. Note the region is not specified in the URL. What you need to do is to grab the static site url from s3 and use that as the origin url (the region will be there).

Solution 3:

This might be late in the game, but check out Lambda@Edge. You can intercept Origin Requests without extension and point them to the index.html document in the folder. These results are cached, so the Lambda is only executed when it gets a new request.