Search code examples
htmlamazon-web-servicesamazon-s3

S3 static pages without .html extension


In serving a static site off of Amazon S3, I'm wondering how to get rid of the .html file extensions for each page.

Right now I have:

mysite.com/             # works fine, serves index.html
mysite.com/mypage.html  # works fine
mysite.com/mypage       # doesn't work

The error for /mypage shows:

404 Not Found

Code: NoSuchKey
Message: The specified key does not exist.
Key: mypage
RequestId: 1089D7A26EFED9AD
HostId: Ud8cFy8Zl1mJ+oFjFOmU1Xacq9+v70KuaJfOc4nFMEPhd66AkLhr4Pj5u0QH6Gog

I have tried setting the Content-Type to text/html, as per this post, but it doesn't fix the problem for me.

How do I get /mypage to serve the file at /mypage.html on S3?


Solution

  • I just had this problem and I'd like to share the solution:

    You have to set the meta data of the file Content-type to text/html AND rename the file removing the .html of the end.

    That way you will be able to reach every page without the file extension.