How to redirect all .JPG to lowercase .jpg using htaccess?

I need it to be so that any time anyone visits url like:
mydomain.com/SomeThiNg/file.JPG
they instead visit:
mydomain.com/SomeThiNg/file.jpg

Like above, ONLY CHANGE THE CASE OF THE JPG EXTENSION.

I tried this but it results in 500 server error:

RewriteEngine On
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI}\.JPG -f
RewriteRule ^(.*)\.JPG$ $1.jpg

RewriteMap can’t go in htaccess files. I’m guessing that’s what’s causing the 500 error. Normally I’d say you should move the RewriteMap to the main server config file (httpd.conf) but you don’t seem to be using “lc” at all so far, so you can probably just delete that line.

pa,

Ditto J_M’s comments on RewriteMap. It’s a very useful tool but, because it can disable a server, its use is limited to the httpd.conf or httpd-vhosts.conf files.

As for your your RewriteCond statement, it, too, is incorrect. Just delete it and you’ll be okay (%{REQUEST_URI} will already contain the .JPG file extension).

As for using the :fire: EVERYTHING :fire: atom, you’re allowing a URI of simply .JPG. (no filename). Change the * to + to require at least one character.

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.