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]

Leave a Reply

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

You are commenting using your 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: