views:

149

answers:

3

Basically a friends just gifted me an old domain to develop, it has quite a few inbound links and its getting a lot of 404 hits.

The basis of the site is to let users hotlink images off it, to put in forum signatures / blog comments and whatnot. I was wondering if there was a way to redirect all these broken image links to a single image which will show up on their page? (basically with a little message saying the sites back up with new images!)

I'm developing the new site on Kohana and using CPanel to admin the hosting (if any of this helps).

+1  A: 

If mod_rewrite is available, you can add a rewrite rule for all pictures not corresponding to any file names, together with a RewriteCond to filter out requests from your own site according to HTTP_REFERER. I think this article will explain this in more detail for you.

Ignas R
+1  A: 

Well, i guess, since you're using PHP, that there's some sort of "retrieve image based on ID" function.

If you're storing your images on a directory try using

file_exists('path/to/my/img.png') ? $image = 'path/to/my/img.png' : $image = 'path/to/my/default/img.png';

If you're storing them in a DB, follow the same logic. Instead of using file_exists() check if the query returned something.

Ben
A: 

The simplest method (on Apache) is:

 ErrorDocument 404 /url/pointing/to/image/you/want/to/serve.jpg

But this will serve up the image for ALL 404s, within the vhost/location/directory you specify this handler for, so a simple typo on a legitimate request will still get this image.

Marc B