View Full Version : mod_rewrite to change file extension case
aus_pilot
01-12-2009, 04: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-13-2009, 12:05 AM
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
Element
04-28-2011, 02:22 AM
I'm having some trouble with mod_rewrite on a server. I'm not sure if it's deactivated, or if my code is wrong. I can't check it it's enabled or not, I am just a hired hand.
SetEnv TZ America/Chicago
DirectoryIndex index.php
AddType application/octet-stream .psd
RewriteEngine On
RewriteRule ^ipbactive.php$ ipbactive.png
oesxyl
04-28-2011, 02:37 AM
I'm having some trouble with mod_rewrite on a server. I'm not sure if it's deactivated, or if my code is wrong. I can't check it it's enabled or not, I am just a hired hand.
SetEnv TZ America/Chicago
DirectoryIndex index.php
AddType application/octet-stream .psd
RewriteEngine On
RewriteRule ^ipbactive.php$ ipbactive.png
ipbactive.png exists on the server? what response you get for the url http://..../ipbactive.php ?
best regards
Element
04-28-2011, 02:50 AM
Can't believe I responded to this thread. I thought I was hitting "New Thread" >.<
The server is giving a 404 on the file ipbactive.png, not a 500 error, so It doesn't seem to be a major error if any.
oesxyl
04-28-2011, 02:59 AM
Can't believe I responded to this thread. I thought I was hitting "New Thread" >.<
:)
The server is giving a 404 on the file ipbactive.png, not a 500 error, so It doesn't seem to be a major error if any.
that mean ipbactive.png doesn't exists and rewrite is working. You need just to upload the file in this case.
best regards
Element
04-28-2011, 03:50 AM
Well what I'm trying to do is mask ipbactive.php with ipbactive.png so that it can be used on the net, as most sites will not accept .php as a image.
It's a dynamic image that changes regularly.
LOL never mind.
oesxyl
04-28-2011, 04:20 AM
Well what I'm trying to do is mask ipbactive.php with ipbactive.png so that it can be used on the net, as most sites will not accept .php as a image.
It's a dynamic image that changes regularly.
LOL never mind.
you don't need rewrite for this or to mask the file, just a header in ipactive.php:
header("Content-Type: image/png");
who ask for this url will first ask for content type, and because will be image/png will use it as a image.
best regards
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.