5

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>

1 Answer 1

7

You have to "think like S3."

"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 /?

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.

Sign up to request clarification or add additional context in comments.

1 Comment

"think like S3". Exactly

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.