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>
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With