[英]AWS S3 redirect rule from index.php to index.html
我有一個公共 AWS S3 存儲桶www.mydomain.com
,我需要將www.mydomain.com/index.php
重定向到www.mydomain.com/index.html
。 我定義的重定向規則不起作用。 http GET 到www.mydomain.com/index.php
返回 404 not found,因為請求的資源不存在。
[
{
"Condition": {
"KeyPrefixEquals": "index.php"
},
"Redirect": {
"ReplaceKeyPrefixWith": "index.html"
}
}
]
要將請求重定向到不同的 object,您需要在 object 上配置元數據。文檔在此處給出了一個示例。 但是,在您的情況下,沒有要重定向的 object。
這里的解決方法是創建index.php
object 並將index.php
的元數據配置為指向存儲桶中的index.html
object。 鏈接文檔對這種情況有一句話,因為它很常見:
Delete the content of page1.html and upload a zero-byte object named page1.html to replace the existing object and redirect page requests.
在您的情況下,沒有要刪除的 object,因此您可以簡單地創建一個零字節 object 作為占位符並將元數據配置為重定向。
有關如何在 aws 控制台或通過 sdk 執行此操作的說明在鏈接的 s3 文檔中。
我只是為此設置了一個測試網站來確認,一切都按預期進行。 這是將元數據添加到存儲桶中的index.php
object 的屏幕截圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.