title: How do I serve index.html in subfolders with S3/Cloudfront?
body: <p>Got a bucket called <code>www.foo.site</code>. In that site there's a landing page, an about page and some pages in a few <code>bar/*</code> folders. Each <code>bar/*</code> has an index.html page: bar/a/index.html, bar/b/index.html etc. </p>
  
  <p>The landing page is running fine (meaning www.foo.site will load when I browse to it) but the <code>/about/index.html</code> page and <code>/bar/index.html</code> pages aren't getting served when I click on my about links etc. If I <code>curl</code> the URLs I get 404. I've tried setting the origin path and origin domain name separately: </p>
  
  <p>First try: </p>
  
  <pre><code>domain name: www.foo.site.s3.amazonaws.com
  origin path: (blank)
  </code></pre>
  
  <p>Second try: </p>
  
  <pre><code>domain name: s3-us-west-1.amazonaws.com
  origin path: www.foo.site
  </code></pre>
  
  <p>Default document is index.html for both. </p>
  
  <p>Neither one worked. <strong>All of the S3 pages mentioned above are directly browsable.</strong> Meaning <a href="https://s3-us-west-1.amazonaws.com/www.foo.site/bar/index.html" rel="noreferrer">https://s3-us-west-1.amazonaws.com/www.foo.site/bar/index.html</a> loads the expected html. </p>
  
  <p>This must be some Cloudfront setting I'm missing. Possibly something in my DNS records? Is it possible to serve html files in S3 "folders" via Cloudfront? </p>