Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

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



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

10+ Year Member


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?


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

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

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:25 pm on May 3, 2006 (gmt 0)

10+ Year Member

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

Featured Threads

Hot Threads This Week

Hot Threads This Month