When moving our Tenseg site to S3 we overlooked some redirects that were in an htaccess file. Most of these we could fix with Jekyll front matter and plugins, but there were two that really needed conditional redirection of a more sophisticated sort. For these we ended up creating some redirection rules in S3 itself.
In the “Static website hosting” property of the S3 bucket we added some XML redirection rules.
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>archives/date/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>blog/</ReplaceKeyPrefixWith>
<HostName>www.tenseg.net</HostName>
</Redirect>
</RoutingRule>
<RoutingRule>
<Condition>
<KeyPrefixEquals>archives/category/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>blog/category/</ReplaceKeyPrefixWith>
<HostName>www.tenseg.net</HostName>
</Redirect>
</RoutingRule>
</RoutingRules>
These rules mean that any reference to the /archives/date directory was turned into a reference to the /blog directory, and any reference to the /archives/category directory was turned into a reference to the /blog/category directory. The odd thing was that without the explicit HostName parameter used above, the redirections were made directly into the raw bucket URL, which was very ugly.