In the "GET data" section, it looks like you are referring to a query string - for example ?foo=1&bar=2 is the path to your URL. This is removed by S3 when you perform object level redirects.
Instead of redirecting certain objects, you can use the routing rules to redirect requests for all objects with a specific prefix to another website, and, if you wish, you can redirect it only if an error occurred while trying to service the original object (for example, 404). Using this method, the query string is sequentially saved.
To redirect every non-existent object from http://example.com/this/directory/* to http://other-site.example.com/that/directory/* , you should use a rule something like this:
<RoutingRule> <Condition> <KeyPrefixEquals>this/directory/</KeyPrefixEquals> <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals> </Condition> <Redirect> <Protocol>http</Protocol> <HostName>other-site.example.com</HostName> <ReplaceKeyPrefixWith>that/directory/</ReplaceKeyPrefixWith> </Redirect> </RoutingRule>
<HttpErrorCodeReturnedEquals> not required if you want to redirect each request of the object corresponding to this prefix to another site, even if the object already exists in the bucket where the rule is configured. <ReplaceKeyPrefixWith> may be set to the same values ββas <KeyPrefixEquals> , or may be completely omitted if you do not need to rewrite the path prefix.
Note that you do not use a slash in the parameters associated with the prefix.
Note that the correct value you want to use for <HttpErrorCodeReturnedEquals> may be 403 ("Forbidden") instead of 404 ("Not Found"). Objects in S3 can be made public either with permissions at the bucket level or at the object level. If the bucket itself is not publicly accessible, objects can still be, if their permissions are set individually. When the bucket itself is not publicly available, (iirc) S3 will not know whether or not an object exists, with 404 on demand without authentication and instead generates a 403 error, so there is an error in the redirection rules.
Michael - sqlbot
source share