如何使用查询字符串参数重定向S3网址? [英] How can I redirect an S3 url using a query string parameter?
问题描述
我要重定向网址" http://mydomain.com/s3?file=test"改为" http://mydomain.com/s3/test.js ",其中mydomain .com是S3静态网站.
I want to redirect the url "http://mydomain.com/s3?file=test" to "http://mydomain.com/s3/test.js" where mydomain.com is an S3 static site.
根据文档,除非我使用Web服务器,否则似乎不可能,但是我想知道是否有办法完全通过S3重定向来完成此操作( http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html ).
Based on the docs it doesn't seem possible unless I use a web server but I wonder if there's a way to do this entirely via S3 redirects (http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html and http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html).
推荐答案
是的,您可以在将s3存储桶配置为静态网站时指定重定向规则来做到这一点.
Yes you can do that by specifying redirection rules while configuring s3 bucket as a static website.
根据您的要求,重定向规则为:
As per your requirement the redirection rules would be:
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>?file=test</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>s3/test.js</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
希望这会有所帮助
这篇关于如何使用查询字符串参数重定向S3网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!