Welcome to WebmasterWorld Guest from 54.162.227.136

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)

WebmasterWorld Senior Member 10+ Year Member



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 Sep 14, 2010 (gmt 0)

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



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

WebmasterWorld Senior Member 10+ Year Member



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

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



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 Sep 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

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



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
 

Featured Threads

Hot Threads This Week

Hot Threads This Month