Amazon S3 does not support the use of .htaccess files for redirection in the case of unfound resource requests. We use them to redirect to an appropriate version specific 404 page for each release, such as
http://docs.cask.co/cdap/current/en/404.html
However, only one such page is permitted for the entire S3 bucket. So, we need a page that, on load, figures out which directory the request came from, and then redirects to the appropriate page.
If the directory requested falls under this:
http://docs.cask.co/<product>/<version>/...
then redirect to
http://docs.cask.co/<product>/<version>/en/404.html
If the directory requested falls under this:
http://docs.cask.co/<product>/...
then redirect to
http://docs.cask.co/<product>/404.html
If the directory requested is above that, and under this,
then redirect to