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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章