在一个静态的网站AWS S3多页 [英] Multiple Pages on a Static Website AWS S3

查看:832
本文介绍了在一个静态的网站AWS S3多页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用托管AWS S3的静态网站(为了方便,易于使用,而且因为它是如此便宜)。

I am hosting a static website using AWS S3 (for convenience, ease-of-use, and because it's so cheap).

当我有多个 HTML 文件。我可以使用 /name_of_file.html 导航到他们。有没有一种方法来路由 HTML 文件,使URL说 / name_of_file 呢?我不喜欢丑的有的.html 扩展在我的网址,我宁愿避免做单页的网站。

When I have multiple HTML documents. I can navigate to them using /name_of_file.html. Is there a way to route the HTML file so the URL says /name_of_file instead? I don't like the ugliness of have a .html extension in my URL and I'd rather avoid do a single page website.

感谢

推荐答案

只要你上传的文件与内容类型头设置为 text / html的,页面会正常工作,如果你只是消除了的.html 拓客月底上传他们当你。

As long as you upload the files with the Content-type header set to text/html, the pages would work fine if you just eliminate the .html extension off of the end when you upload them.

否则,我想到的唯一选择是使用的 S3重定向,但只允许你导航页面,而无需对最终的html的 - 但你随后看重定向到的.html命名文件和浏览器html的仍然会显示在地址栏,所以这可能不是一个赢家。

Otherwise, the only option that comes to mind is to use S3 Redirects, but that only allows you to "navigate to" the pages without the .html on the end -- but you'll subsequently see the browser redirected to the .html-named file and the .html will still show up in the address bar, so that's probably not a winner.

另外 - 这是一个相当舒展,但也许值得一提的 - 你可以通过漏斗一个EC2实例上运行HAProxy的或请求另一个反向代理服务器并重写(不定向)请求不包含一个点追加。 HTML到最后,但那种撤销的易用性方面 - 虽然它可能让你举办了很多的网站不是每个账号限100桶,如果你需要的是,通过保持一个以上的网站在一个桶和追加preFIX到每个请求的对象路径也是如此。在同一AWS区域内的EC2和S3之间的数据传输是免费的,所以这不会产生额外的带宽费用 - 该实例本身只是费用。

Alternately -- and this is quite a stretch but perhaps worth mentioning -- you could funnel the requests through an EC2 instance running HAProxy or another reverse-proxy server and rewrite (not redirect) requests not containing a dot to append '.html' to the end, but that sort of undoes the "ease of use" aspect -- although it could allow you to host a lot more sites than the 100 buckets per account limit, if you needed that, by keeping more than one "site" in a single bucket and appending a prefix to each requested object path as well. Data transfer between EC2 and S3 within the same AWS region is free, so this wouldn't incur additional bandwidth charges -- just the cost of the instance itself.

更新(从注释):

在AWS控制台可能是因为选择的Content-Type作为元数据键,然后只提出几个选择,包括文字/ plain和text / RTF但不是text / html的...但值略有下降反直觉-down列表只提供建议。任何半理智的将被接受,在这里。

The AWS console may be slightly counter-intuitive since selecting Content-Type as the metadata Key then only suggests a few choices, including text/plain and text/rtf but not text/html... but the "Value" drop-down list is only offering suggestions. Anything semi-sensible will be accepted, here.

  • (斗)选择操作→上传
  • 单击添加文件
  • 选择要上传的文件,在对话框中
  • 单击设置方式,然后选中所有适用的箱
  • 单击设置权限并勾选让一切公开(如适用)
  • 单击设置元数据
  • 单击添加更多的元数据
  • 在密钥下拉列表中,选择内容类型,然后键入 在值框中的text / html的。 - 这不是多数民众赞成提供了一个选择,但是这是常见的类型只有一个列表,并不会限制你可以把箱子是什么
  • 点击开始上传
  • (in bucket) choose actions → upload
  • click "add files"
  • select the file to upload, in the dialog box
  • click "set details" and check any applicable boxes
  • click "set permissions" and check "make everything public" (if applicable)
  • click "set metadata"
  • click "add more metadata"
  • in the "Key" drop-down list, choose "Content-Type" and then type "text/html" in the "Value" box -- it's not a choice that's offered, but this is only a list of common types and doesn't limit what you can put in the box.
  • click "start upload"

这篇关于在一个静态的网站AWS S3多页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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