Forum Moderators: phranque

Message Too Old, No Replies

Serving GIF as a JPG

         

Insomniak

10:07 pm on Nov 15, 2007 (gmt 0)

10+ Year Member




Hi, hope this is the proper forum,
Im really not sure how this might be done.

I have a JPG banner hosted on my site for hotlinking and would like to replace it with an animated GIF keeping all the links active with the JPG extension.

Is that possible through .htaccess or something?

Thanks

phranque

5:09 am on Nov 16, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



something like this might work to internally rewrite all /path/to/file.name.jpg to /path/to/file.name.gif:
Options +FollowSymLinks
RewriteEngine on
#
# internally rewrite .jp(e)g to equivalent .gif
RewriteRule ^(.*)\.jpe?g$ $1.gif [L]

you would normally prefer not to use the ambiguous, greedy and promiscuous '.*' in your regexp, but i didn't see a good way out of this one.

Insomniak

12:09 am on Nov 19, 2007 (gmt 0)

10+ Year Member




Hey thanks,
it's actually only a single file I need to do this with so I assume I can just put the filename in and not even use wildcards.

phranque

2:16 pm on Nov 19, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you definitely want to be as specific as possible with your regular expression.
maybe like:
RewriteRule ^banner.jpg$ animated.gif [L]