How do I serve index.html in subfolders with S3/Cloudfront?

Here are a couple of resources that are helpful when serving index.html from S3 implicitly via https://domain/folder/ rather than having to explicitly use https://domain/folder/index.html:

  • Serving index pages from a non-root location via CloudFront
  • Serving index pages from a non-root location via CloudFront (now unavailable)
  • Implementing Default Indexes in CloudFront Origins Using Lambda@Edge

The key thing when configuring your CloudFront distribution is:

do not configure a default root object for your CloudFront distribution

If you configure index.html as the default root object then https://domain/ will correctly serve https://domain/index.html but no subfolder reference such as https://domain/folder/ will work.

It's also important to not use the dropdown in Cloudfront when connecting the CF distribution to the S3 bucket. You need to use the URL for the S3 static site instead.