homepage Welcome to WebmasterWorld Guest from 50.17.86.12
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Displaying a .gif instead of a .jpg
using .htaccess
le_gber

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4201566 posted 10:47 am on Sep 14, 2010 (gmt 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.

 

topr8

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



 
Msg#: 4201566 posted 10:58 am on Sep 14, 2010 (gmt 0)

surely the client browser still thinks it's a jpg? and thus won't render it anyway

le_gber

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4201566 posted 11:10 am on Sep 14, 2010 (gmt 0)

@topr8 probably the reason why then. Interestingly enough a 301 redirect seems to have done the trick. Thanks.

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4201566 posted 11:28 am on Sep 14, 2010 (gmt 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.
le_gber

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4201566 posted 12:15 pm on Sep 14, 2010 (gmt 0)

@g1smd - thanks for the clarification, guess I need to read up on Apache config ;)

jdMorgan

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



 
Msg#: 4201566 posted 10:59 pm on Sep 14, 2010 (gmt 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved