Apache

ID #35

How do I make my own Error Documents to replace the default ones like "404 Not Found"?

Applies to: Grid System

You can make your own error pages by creating the html files that you want displayed for each error code and by designating them in an .htaccess file in your www directory.

For example, if you want a web page called 404.html to replace the default error page, put the following line in your .htaccess file:

ErrorDocument 404 /404.html

You can do the same with other error codes. Be sure that the filename of the web page that you designate in your .htaccess file is the name of an actual web page that you have created and uploaded.

Since this error page will be loaded from any directory on your site, remember to make any link or image path root relative images/myimage.jpg as opposed to images/myimage.jpg.

Check out the Apache documentation on ErrorDocument directives.

Also, this A List Apart article has some helpful tips as well.


Last update: 2010-09-29 16:19
Author: FAQ Admin
Revision: 1.2

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 1 (1 Vote)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ

Comment of Anonymous:
One of the features of newer Microsoft browsers is the "Friendly 404 Error" page which overrides any custom 404 page that is smaller than 512 bytes. Make sure your custom 404 page is over 512 bytes. Adding a graphic is an easy way to make sure you're over the minimum size.
Added at: 2002-04-17 10:12

Comment of Anonymous:
You must create the file named ".htaccess". It is just a plain text file and you put directives on it one per line.
Added at: 2003-04-09 11:57

Comment of Anonymous:
If you find that an .htaccess file already exists, just add your new directives either before or after the ones that are already there.
Added at: 2003-04-09 11:57

Comment of Anonymous:
The annoying little reminders that either someone has miswritten the URL, deleted the file you are looking for, or the net spirits are against you and will see to it you will never find the information you are looking for. So you can give some information, graphics, etc at 404.html page, this is more useful for visitor too

---------------------------------------------------------
Web Directory -- http://www.javaedition.com/
Added at: 2009-01-26 00:46