title: Serve index file instead of download prompt
body: <p>I have my website hosted on S3 with CloudFront as a CDN, and I need these two URLs to behave the same and to serve the index.html file within the directory:</p>
  
  <p><code>example.com/directory</code>
  <code>example.com/directory/</code></p>
  
  <p>The one with the <code>/</code> at the end incorrectly prompts the browser to download a zero byte file with a random hash for the name of the file. Without the slash it returns my 404 page.</p>
  
  <p>How can I get both paths to deliver the index.html file within the directory?</p>
  
  <p>If there's a way I'm "supposed" to do this, great! That's what I'm hoping for, but if not I'll probably try to use Lambda@Edge to do a redirect. I need that for some other situations anyway, so some instructions on how to do a 301 or 302 redirect from Lambda@Edge would be helpful too : ) </p>
  
  <p><strong>Update (as per John Hanley's Comment)</strong></p>
  
  <p><code>curl -i https://www.example.com/directory/</code></p>
  
  <pre><code>HTTP/2 200 
  content-type: application/x-directory
  content-length: 0
  date: Sat, 12 Jan 2019 22:07:47 GMT
  last-modified: Wed, 31 Jan 2018 00:44:16 GMT
  etag: "[id]"
  accept-ranges: bytes
  server: AmazonS3
  x-cache: Miss from cloudfront
  via: 1.1 [id].cloudfront.net (CloudFront)
  x-amz-cf-id: [id]
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>CloudFront has one behavior set, forwarding http to https and sending the requests to S3. It also has a 404 error route under the errors tab.</p>