• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

404 error for image: can I display an error image?

Is there a way to let apache serve a custom error image when an image is requested that does not exist on the server?
0
grexx
Asked:
grexx
  • 3
  • 2
1 Solution
 
Diablo84Commented:
You can handle this with HTML if this is an option, eg:

<img src="animage.jpg" onerror="this.src='error_image.jpg'">

If the first image cannot be loaded the later will be loaded in its place.
0
 
grexxAuthor Commented:
It's a nice option, but it's especially meant for cases where I cannot control the html. So it has to be set on the server side.
0
 
wesly_chenCommented:
Hi,

    You might want to check the following URL:
http://www.plinko.net/404/howto.asp?article=11

    Basically, create a file called .htaccess in the root directory of the server (the one you refer to as '/') and
have the following line in .htaccess:
-------
ErrorDocument 404 /errors/custom404.html
---------

   Then edit your own custom404.html page.

Regards,

Wesly
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
grexxAuthor Commented:
Well, that's for *pages*. I need the same thing but then for *images*. In a page you refer to an image, but that specific image doesn't have to be available. In that case, I want to be able to display a standard error-image.
0
 
wesly_chenCommented:
Hi,
   You can redirect to a PERL/CGI script as follow:
------
ErrorDocument 404 /errors/custom404.cgi
-----
   Then in the CGI script, check the page extention (jpg, gif, or html)
and redirect to different 404 error message page. (404image.html and 404general.html)

   And you customize the those pages (404image.html and 404general.html).

Wesly
0
 
wesly_chenCommented:
By the way, error code 404 means the page in the URL is not found. This URL can be an HTML, CGI, or image.

Wesly
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now