Custom Error Pages
When our servers display an error page to your visitors, the default page is terse and not very helpful.
You can change these error pages so they're more useful and match the rest of your site in appearance. For example, you could change the "Not Found" page to show a "site map", helping your visitor find the correct page.
Pages you can change
You can easily change several different error pages:
- 401 Authorization Required: displayed if a visitor tries to access a password-protected page but doesn't know the password.
- 403 Forbidden: displayed if a visitor tries to view a directory that does not contain an index file (such as "index.html" or "index.htm"), or when a visitor tries to view a file which does not have "world-readable permissions".
- 404 Not Found: displayed if a visitor tries to view a page that doesn't exist.
- 412 Precondition Failed: displayed if the server believes a security "hacking" attempt is taking place.
- 500 Internal Server Error: displayed if the server runs a CGI script that has syntax errors, or if you create a
.htaccessfile that has syntax errors.
- 503 Service unavailable: displayed if a single computer makes too many simultaneous connections (usually, more than 100 connections at the same time) to the Web server.
Note that each page has a three-digit error number (such as "404" for "Not Found").
Once you've decided which error pages you want to customize, create a normal Web page with your custom text and name it error401.html, error403.html, error404.html, error412.html, error500.html, or error503.html, as appropriate (using the error numbers shown above). Then upload or publish the page(s) to the top level of your Web page directory, using FTP or FrontPage just as you would publish any other Web page.
If you want to use server-side includes in your error pages, you can make your error pages be ".shtml" pages instead: just name them error401.shtml, error403.shtml, error404.shtml, error412.shtml, error500.shtml, or error503.shtml.
In the same way, if you want to use PHP for your error pages, name them error401.php, error403.php, error404.php, error412.php, error500.php, or error503.php.
That's all it takes! If you have trouble, make sure the file names are all lowercase, and that they end in ".html", ".shtml" or ".php", and not ".htm".
Use absolute links in error pages
If you use any graphics or links in an error page, don't use "relative links". Instead, make all your links "absolute links" that start with "http://www.example.com/". The reason for this is that your error document might be called into service from a variety of different locations on your site, depending on where the error occurs. Relative links point to locations that are relative to the current page (hence the name), but you don't know what the current page will be when your error document is displayed. Forcing your links to start with "http://www.example.com/" guarantees they're correct no matter what page the visitor was originally trying to view.
Can I override other error pages?
The errors mentioned above aren't the only possible errors that a Web server can display, although they're by far the most common. There are ways to override other error codes, too, if you're an expert user with experience with Apache ".htaccess" files. The Apache ErrorDocument directive explains how to do it.
A note about Internet Explorer and "friendly error messages"
Microsoft Internet Explorer has an inexplicable "feature": if a Web server sends a custom error page that is shorter than 512 bytes in size, Internet Explorer shows its own internal error page instead of the one from the server. Microsoft calls this "friendly HTTP error messages".
You can turn this "feature" off in your Web browser (search the Web for "Show friendly HTTP error messages" to see how), but you probably want to make sure that other people don't encounter it. To do that, just make sure your custom error pages are larger than 512 bytes in size (including the HTML tags and so forth). You can use invisible HTML comment text if necessary.
In practice, most custom error pages will be longer than 512 bytes anyway, so this isn't usually a problem. Our customers usually only encounter the problem when using a very short test phrase, in which case it can be very puzzling.