S3静态页面没有.html扩展名 [英] S3 static pages without .html extension

查看:348
本文介绍了S3静态页面没有.html扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为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

/ mypage 的错误显示:

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 /mypage.html on S3?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆