PDA

View Full Version : mod_rewrite to change file extension case


aus_pilot
01-12-2009, 03:38 PM
Hi guys - first post here.....

I was wondering if anyone know how to use mod_rewrite to change file name extensions on a website from uppercase to lower.

This is what I have so far...


RewriteRule ^/?([a-z/]+)\.JPG$ $1.jpg [L]

Any ideas ??

oesxyl
01-12-2009, 11:05 PM
Hi guys - first post here.....

I was wondering if anyone know how to use mod_rewrite to change file name extensions on a website from uppercase to lower.

This is what I have so far...


RewriteRule ^/?([a-z/]+)\.JPG$ $1.jpg [L]

Any ideas ??
if you can and if you have many extension, not only jpg, a better idea is to use mod_speling

http://httpd.apache.org/docs/2.2/mod/mod_speling.html

or mod_mime:

AddType image/jpeg .jpg .jpeg


http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addtype

with mod rewrite try this:

RewriteRule ^(.+)\.JPG$ $1.jpg

I guess will work, but that's depend on server setup, you must try in your case
add L if you are sure you want to be last rule

http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html

regards