homepage Welcome to WebmasterWorld Guest from
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

10+ Year Member

Msg#: 6124 posted 5:58 am on Apr 27, 2006 (gmt 0)


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?



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

Msg#: 6124 posted 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.



10+ Year Member

Msg#: 6124 posted 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