S3静态主机重定向和剥离段 [英] S3 static host redirect and strip slug

查看:75
本文介绍了S3静态主机重定向和剥离段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建一个静态网站重定向规则来重定向www.domain1.com/* --> www.domain2.com而不保持该状态?

Is it possible to create a static website redirect rule that redirects www.domain1.com/* --> www.domain2.com without maintaining the slug ?

如果允许使用通配符,则将发生以下情况:

Something like this if wildcard was allowed:

<RoutingRules>
  <RoutingRule>
  <Condition>
    <KeyPrefixEquals>*</KeyPrefixEquals>
  </Condition>
  <Redirect>
    <HostName>www.domain2.com</HostName>
    <ReplaceKeyPrefixWith>/</ReplaceKeyPrefixWith>
  </Redirect>
  </RoutingRule>
</RoutingRules>

推荐答案

您必须像S3一样思考".

You have to "think like S3."

键前缀"是前缀,根据定义,空字符串是所有字符串的前缀-因为left(anystring,len('')) == ''.

"Key prefix" is a prefix, and by definition, an empty string is the prefix of all strings -- because left(anystring,len('')) == ''.

因此,您不需要通配符-您应该可以简单地说一遍:

So you don't need a wildcard -- you should be able to simply say this:

<KeyPrefixEquals></KeyPrefixEquals>

然后,您不想替换前缀-您希望替换整个密钥,因此看起来像这样:

Then, you don't want to replace the prefix -- you want to replace the entire key, so that looks like this:

<ReplaceKeyWith></ReplaceKeyWith>

您问...为什么它是空的而不是/?

You ask... why is it empty instead of /?

这是因为在S3模型中,键空间不是以/开头. bucket.example.com/foo的路径为/foo,但其密钥实际上为foo.

It's because, in the S3 model, the keyspace does not begin with /. bucket.example.com/foo has a path of /foo but its key is actually foo.

这篇关于S3静态主机重定向和剥离段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆