[英]Redirect rule for AWS S3 bucket as in htaccess
我有一个网站托管在 apache 服务器上,我使用这个 .htaccess 重写规则让 website.com/article/title-here 像 website.com/article.html?title=title-here
这是 .htaccess 代码:
RewriteEngine On
RewriteRule ^/?article/([^/d]+)/?$ article.html?title=$1 [L,QSA]
问题是我想将 website.com 移动到 Amazon S3 存储桶中,但 .htaccess 无法正常工作。
我尝试使用 static 主机的重写规则如下:
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>article.html?title=</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>article/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
您没有 url 重写或 S3 中的任何类似内容。
S3只是一个存储解决方案,而不是一个完整的网络服务器。
最接近您想要的是使用 CloudFront 设置分发并添加Custom Error Responses
,这些响应在404
和403
上重定向到已知项目(在您的案例中为文章)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.