First off, it's not as hard as you think! These directions are for the
popular Apache web browser but odds are pretty
darn good that's what server you have anyway! if not, then a quick
google of "adding a 404 error page" coupled with
the name of your web server will probably do the trick!
Step One: Modify the httpd.conf file
The first step, and perhaps the most challenging, is to find your Web server
configuration file - often called httpd.conf
- and find the block of statements
that define the location and behavior of your particular site. This file is commonly
found at /etc/httpd/httpd.conf
similar location: if you can't find it, ask your system administrator.
On a typical
server configuration, it might look like this:
Your server might have dozens (or more) of these VirtualHost blocks in
the configuration file: make sure you find the one for your exact domain
name before you make any modifications.
Now that you've found this section, you need to add an ErrorDocument
handler that specifies the exact numeric code and the name of the file to
serve up (or CGI script to run) when that error is encountered. Here's
how that might well look:
ErrorDocument 404 /errordoc-404.shtml
In this case, when error 404 is encountered - page or file not found - then
the file errordoc-404.shtml
will be served up (and notice that you
can have server-side includes (SSI) in error documents if you'd like. One
trick, though, is to remember that error pages can pop up anywhere in your
site heirarchy, so make sure all your graphic references, links to other areas
on the site, etc, are absolute references
, that they start with '/' or,
in extreme cases, 'http:'.