编辑AWS S3存储桶重定向规则,以重定向到相同URL的参数(url)

时间:2021-01-12 10:45:52

For a url of the form

对于表单的网址

https://www.example.com/i/http://some-image-url.png

https://www.example.com/i/http://some-image-url.png

Is it possible to redirct to http://some-image-url.png (param after i/)?

是否有可能重新编写为http://some-image-url.png(i /后的参数)?

with just Editing Redirection rule of AWS S3 bucket website.

只需编辑AWS S3存储桶网站的重定向规则。

<RoutingRules>
<RoutingRule>
    <Condition>
        <KeyPrefixEquals>i/</KeyPrefixEquals>
    </Condition>
    <Redirect>
        [[config for redirecting to http://some-image-url.png]]
    </Redirect>
</RoutingRule>

Doc Link: http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax

Doc Link:http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax

1 个解决方案

#1


1  

From experience, albeit last year, the routing rules and conditions do not allow wildcards, however you can redirect to a different host, so you would have to do something like

根据经验,尽管去年,路由规则和条件不允许使用通配符,但是您可以重定向到不同的主机,因此您必须执行类似的操作

<?xml version="1.0"?>
<RoutingRules>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals>i/http://some.image.host/some-image.png</KeyPrefixEquals>
    </Condition>
    <Redirect>
      <HostName>some.image.host</HostName>
      <ReplaceKeyPrefixWith>some-image-url.png</ReplaceKeyPrefixWith>
  </RoutingRule>
</RoutingRules>

#1


1  

From experience, albeit last year, the routing rules and conditions do not allow wildcards, however you can redirect to a different host, so you would have to do something like

根据经验,尽管去年,路由规则和条件不允许使用通配符,但是您可以重定向到不同的主机,因此您必须执行类似的操作

<?xml version="1.0"?>
<RoutingRules>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals>i/http://some.image.host/some-image.png</KeyPrefixEquals>
    </Condition>
    <Redirect>
      <HostName>some.image.host</HostName>
      <ReplaceKeyPrefixWith>some-image-url.png</ReplaceKeyPrefixWith>
  </RoutingRule>
</RoutingRules>