使用 aws S3 架設 static website(靜態網頁), 網頁內的 link 只有指向目錄, 沒有指向 index, html 怎麼辦?

ref: FROM stack overflow

  1. 首先把網站上傳到 s3 bucket 上安置好, 並且設定可以外部瀏覽.
  2. 到 CloudFront distributions 設定如下的規定
    • Default Root Object: index.html
    • Origin Domain Name: S3 bucket domain, 例如: rel20251024.s3.amazonaws.com
  3. 另外也可以加上 error page 或是 404 的設定
    • HTTP Error Code: 403: Forbidden or 404: Not Found, in case of S3 Static Website
    • Customize Error Response: Yes
    • Response Page Path: /index.html
    • HTTP Response Code: 200: OK
    • Click on Create

以上資料參考
https://stackoverflow.com/questions/16267339/s3-static-website-hosting-route-all-paths-to-index-html

另外如果有需要將你的靜態網站使用 https 連線的話可以參考這一篇
https://blog.johnwu.cc/article/aws-s3-cloudfront-ssl-%E9%9D%9C%E6%85%8B%E7%B6%B2%E9%A0%81%E6%9E%B6%E7%AB%99%E6%95%99%E5%AD%B8.html

More From Author

AWS 大當機, 市佔1/3的老大也是會抖的!!!

兩種小成本架設靜態網站的方法 Github vs AWS S3

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *