具有 404 错误的子文件夹的 AWS S3 重定向规则
AWS S3 redirect rules for subfolders with 404 error
有没有可能像这样在 S3 中进行重定向?
domain/us/wrongurl.html redirect to this ➜ domain/us/404.html
domain/uk/wrongurl.html redirect to this ➜ domain/uk/404.html
domain/wrongurl.html redirect to this ➜ domain/404.html
最接近的解:
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>US</KeyPrefixEquals>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>domain.name</HostName>
<ReplaceKeyPrefixWith>US/404.html#</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
假设您在存储桶上设置了静态网络托管,您可以设置存储桶级别的错误文档。
但有一个警告,
When an error occurs, Amazon S3 returns an HTML error document. If you have configured your website with a custom error document, Amazon S3 returns that error document. However, when an error occurs, some browsers display their own error message, ignoring the error document Amazon S3 returns. For example, when an HTTP 404 Not Found error occurs, Chrome might display its own error ignoring the error document that Amazon S3 returns.
有没有可能像这样在 S3 中进行重定向?
domain/us/wrongurl.html redirect to this ➜ domain/us/404.html
domain/uk/wrongurl.html redirect to this ➜ domain/uk/404.html
domain/wrongurl.html redirect to this ➜ domain/404.html
最接近的解:
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>US</KeyPrefixEquals>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>domain.name</HostName>
<ReplaceKeyPrefixWith>US/404.html#</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
假设您在存储桶上设置了静态网络托管,您可以设置存储桶级别的错误文档。
但有一个警告,
When an error occurs, Amazon S3 returns an HTML error document. If you have configured your website with a custom error document, Amazon S3 returns that error document. However, when an error occurs, some browsers display their own error message, ignoring the error document Amazon S3 returns. For example, when an HTTP 404 Not Found error occurs, Chrome might display its own error ignoring the error document that Amazon S3 returns.