Welcome to WebmasterWorld Guest from 54.159.50.111

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Displaying a .gif instead of a .jpg

using .htaccess

     
10:47 am on Sep 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2003
posts:1550
votes: 0


Hi guys,

I am trying to display a .gif instead of a .jpg using htaccess. I have added the following to both the root folder and my images folder but it doesn't seem to work:


RewriteCond %{REQUEST_FILENAME} ^foo.jpg
RewriteRule ^images/foo.jpg$ /images/foo.gif [L]


Any help greatly appreciated.
10:58 am on Sept 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Apr 19, 2002
posts:3171
votes: 8


surely the client browser still thinks it's a jpg? and thus won't render it anyway
11:10 am on Sept 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2003
posts:1550
votes: 0


@topr8 probably the reason why then. Interestingly enough a 301 redirect seems to have done the trick. Thanks.
11:28 am on Sept 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


A 301 redirect tells the browser to fetch a new URL.

That new URL will include the correct extension.

An internal rewrite cannot do that; imagine asking for an HTML page and having an Excel spreadsheet file returned for that
/filename.html
URL request.
12:15 pm on Sept 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 14, 2003
posts:1550
votes: 0


@g1smd - thanks for the clarification, guess I need to read up on Apache config ;)
10:59 pm on Sept 14, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Assuming that you also have the Options and RewriteEngine directives required to enable mod_rewrite, the only problem with that code in the unnecessary RewriteCond, that is in fact interfering with its function...

Jim