Using mod_rewrite to rewrite a URL to lowercase

While moving some of our download URLs to Amazon’s S3 service we came across the problem, that some of the URLs out there use mixed case (which was no problem with our windows servers, they ignore uppercase/lowercase in URLs) while Amazon’s S3 is case senitive.

We needed to rewrite all our URLs to lower case before redirecting the downloads to S3.

Here is the trick:


RewriteMap lowercase int:tolower
RewriteRule ^/download/(.*) http://your-bucket-at-amazon.domain/download/${lowercase:$1} [L,NC]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: