Martin
Martin

Reputation: 2785

Ignoring file extensions on Amazon S3

I want to create a simple rewrite rule that ignores any extension that is added to a request. For example, both foo.bar and foo.don would point to the file foo. If this is not possible, can I add aliases to files? A third option is to upload an extra version of the file with the extension for every extension that the file should be available, but I don't think this is a good solution.

Upvotes: 0

Views: 455

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179124

Redirection rules in S3 only work on prefixes, not extensions or with regexes. You can, however, create empty objects at the alternative paths, with x-amz-website-redirect-location in the metadata, which will redirect the request elsewhere with a 301 Moved Permanently response. This, at least, prevents you from incurring redundant storage charges.

Like all redirects, this feature only works on requests sent to the S3 web site endpoint, not the REST endpoint.

http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html

The alternative would be to use a reverse proxy server in front of the bucket, to rewrite requests before they hit S3.

Upvotes: 1

Related Questions