AWS S3 RoutingRule with wildcard condition
amazon-s3, amazon-web-services
Solution
The Routing Rules don't allow wildcards -- but couldn't you just put a custom redirect in for any 404 errors? See example#2 here: Example 2: Redirect requests for a deleted folder to a page Just change the condition to:
<HttpErrorCodeReturnedEquals>404 </HttpErrorCodeReturnedEquals>
Would that work?
Problem
I have a set of user folders with the same folder structure, but different content, stored in S3. ``` /user/userA/application/folder/structure/file.xml /user/userB/application/folder/structure/file.xml ``` I would like to redirect the user to a fallback folder, (with fallback content) if the s3 folder structure don't exist for that user yet. ``` /user-fallback/application/folder/structure/file.xml ``` I've tried to add a wildcard parameter to my Redirection Rules, but S3 is reading `*` as a literal ``` <RoutingRules> <RoutingRule> <Condition> <KeyPrefixEquals>user/*/</KeyPrefixEquals> <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals> </Condition> <Redirect> <ReplaceKeyPrefixWith>user-fallback/</ReplaceKeyPrefixWith> </Redirect> </RoutingRule> </RoutingRules> ``` So only urls starting with `/user/*/` are being correctly redirected to the `user-fallback` folder structure. I have more than 20 users, so creating individual RoutingRules wouldn't work either (S3 has a routing rule limit) Any ideas?