Skip to content

Instantly share code, notes, and snippets.

@4lun
Last active June 4, 2017 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4lun/b1926ea9ad435b29ec9006908cf2318f to your computer and use it in GitHub Desktop.
Save 4lun/b1926ea9ad435b29ec9006908cf2318f to your computer and use it in GitHub Desktop.
Redirect all requests from an S3 bucket to another domain with explicit path (example redirects all requests to newdomain.com/?referrer=olddomain). Substitute 404 code with 403 if bucket is not publicly readable. Note this all assumes there are no matching files in the bucket.
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>newdomain.com</HostName>
<ReplaceKeyWith>?referrer=olddomain</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment