PDA

View Full Version : mod rewrite jpg to gif?


johnfl68
02-17-2008, 12:55 AM
Hello all, I'm not all up with htaccess mod rewrites. Is it possible to do one that would redirect links for a jpg image to a gif image (same size)?

I have 4 banners that have external links, and the next update doesn't look good as a jpg, but looks good as a gif. I don't want to have everyone that is currently linked to have to update the code on their end, but do this on my end if at all possible. And then I would also have the ability to change back to a jpeg at a later date if needed.

For example:
images/imu728x90.jpg redirects to images/imu728x90.gif

Thanks for any insight as always!

John

kitchin
02-17-2008, 05:34 AM
Looky here, that exact example is in "RedirectMatch" on this page:
http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirectmatch
Just change "anothersever.com" to your sameserver.com, works the same.

You could insert a "301" after "RedirectMatch" to indicate it's permanent, otherwise it is 302 Temporary.

johnfl68
02-17-2008, 07:11 PM
Thanks! That pointed me in the right direction.

I ended up using the following:


Redirect 307 /images/banners/imu728x90.jpg http://www.mywebsite.com/images/banners/imu728x90.gif

Since there was only 4 files I needed to do this to, this seemed to be the best way.

From what I could tell, the 307 Temporary Redirect status seemed to be the best to fit this, as it is temporary, and will change back in the future.

John

kitchin
02-17-2008, 07:42 PM
Glad to hear it. I'm not familiar with 307, but I guess if a browser doesn't understand it, it will assume 302. Maybe somebody else can answer that small point, which is no big deal in any case! The odd history of 302 vs. 307 is in the "3xx" section here:
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection