S3的静态网站托管路由的所有路径的index.html [英] S3 Static Website Hosting Route All Paths to Index.html

查看:552
本文介绍了S3的静态网站托管路由的所有路径的index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用S3举办一个JavaScript的应用程序,将使用HTML5 pushStates。问题是,如果用户书签任何网址,它不会解决任何事情。我需要的是把所有的URL请求,服务在我的S3存储桶根的index.html,而不是仅仅做一个完整的重定向的能力。然后我的JavaScript应用程序可以解析的网址和服务于正确的页面。

I am using S3 to host a javascript app that will use HTML5 pushStates. The problem is if the user bookmarks any of the URLs, it will not resolve to anything. What I need is the ability to take all url requests and serve up the root index.html in my S3 bucket, rather than just doing a full redirect. Then my javascript application could parse the URL and serve the proper page.

有没有办法告诉S3服务中的index.html所有URL请求,而不是做重定向?这将是类似于设置Apache处理由提供了一个index.html作为在这个例子中所有的请求:的http:// stackoverflow.com/a/10647521/1762614 。我真的想避免运行Web服务器只是为了处理这些路线。从S3所做的一切是非常有吸引力。

Is there any way to tell S3 to serve the index.html for all URL requests instead of doing redirects? This would be similar to setting up apache to handle all incoming requests by serving up a single index.html as in this example: http://stackoverflow.com/a/10647521/1762614. I would really like to avoid running a web server just to handle these routes. Doing everything from S3 is very appealing.

推荐答案

标记的解决方案是不坏,但还有一个更简单的解决方案来表示。在在错误文档你的水桶性能只要使用同一个文件中的索引文件。像骨干JavaScript框架,AngularJS等,将工作开箱即用这种方式和页面刷新将全面支持。

Mark solution is not bad but there is an even simpler solution to that. In your bucket properties in the Error Document just use the same file as the Index Document. JavaScript frameworks like Backbone, AngularJS etc, will work out of the box this way and page refresh will be fully supported.

这篇关于S3的静态网站托管路由的所有路径的index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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