S3 静态网站托管将所有路径路由到 Index.html - S3 Static Website Hosting Route All Paths to Index.html

问题:

I am using S3 to host a javascript app that will use HTML5 pushStates.我正在使用 S3 来托管将使用 HTML5 pushStates 的 javascript 应用程序。 The problem is if the user bookmarks any of the URLs, it will not resolve to anything.问题是如果用户将任何 URL 加入书签,它不会解析为任何内容。 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.我需要的是能够接受所有 url 请求并在我的 S3 存储桶中提供根 index.html,而不仅仅是执行完全重定向。 Then my javascript application could parse the URL and serve the proper page.然后我的 javascript 应用程序可以解析 URL 并提供正确的页面。

Is there any way to tell S3 to serve the index.html for all URL requests instead of doing redirects?有没有办法告诉 S3 为所有 URL 请求提供 index.html 而不是进行重定向? This would be similar to setting up apache to handle all incoming requests by serving up a single index.html as in this example: https://stackoverflow.com/a/10647521/1762614 .这类似于通过提供单个 index.html 来设置 apache 来处理所有传入请求,如本例所示: https : //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.从 S3 开始做所有事情都非常有吸引力。


解决方案:

参考一: https://stackoom.com/question/16FsR
参考二: S3 Static Website Hosting Route All Paths to Index.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章