S3 static host redirect and strip slug

amazon-s3

Solution

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`.

Problem

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> ```

Original source