homepage Welcome to WebmasterWorld Guest from 54.167.173.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
404 - send a default .jpg if the requested file is not found
58sniper




msg:1524524
 5:58 am on Apr 27, 2006 (gmt 0)

Greetings!

Not sure whether this is a ErrorDocument issue or a mod_rewrite issue, so I can't tell what to search for.

I have a directory with 18,000+ mugshots. One of my content pages shows some of these mugshots, but the html data is pulled via AJAX. Since one page could have well more than 100 records, I'm reluctant to do a server side check for each file before sending the XML data.

What I'd like to do is set an .htaccess line to send a "no_mugshot.jpg" if the requested mugshot isn't located.

I tried doing
ErrorDocument 404 /dev/mugs/no_mugshot.jpg

but that doesn't work.

Am I on the right path?

 

jdMorgan




msg:1524525
 6:12 pm on Apr 28, 2006 (gmt 0)

How doesn't it work? More details would help.

One problem is that ErrorDocument means what it says -- document. And an image is not a document, so that may not work on first principles. But I haven't tested it.

There are several ways to do this. One is to use mod_rewrite's RewriteCond directive to check to see if the requested image exists, but that may have a performance impact, as you fear.

Jim

58sniper




msg:1524526
 10:25 pm on May 3, 2006 (gmt 0)

I get a 404 for the image, and an additional error saying there was a problem processing.

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