S3静态页面没有.html扩展名 [英] S3 static pages without .html extension
问题描述
在为Amazon S3提供静态网站时,我想知道如何摆脱每个页面的 .html
文件扩展名。
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
我试着将 Content-Type
设置为 text / html
,按照这篇文章,但它不能解决我的问题。
I have tried setting the Content-Type
to text/html
, as per this post, but it doesn't fix the problem for me.
如何获取 / mypage
以
How do I get /mypage
to serve the file at /mypage.html
on S3?
推荐答案
我刚刚遇到了这个问题,我想分享解决方案:
I just had this problem and I'd like to share the solution:
您必须将文件 Content-type
的元数据设置为 text / html
并重命名删除结尾的 .html
的文件。
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.
这篇关于S3静态页面没有.html扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!