Telnet
SSL
Redirection
Protected Directories
E-Mail
Mail Lists
PHP
SQL
SubDomains
CGI
SSH
Real Audio
Control Panel
Web Stats
Custom Error Pages
Click to get help
Custom Error Pages


STEP ONE - CREATE THE PAGE

You can create error message pages for all error types, but for most sites, just creating a custom 404 Not Found error is adequate, as these are the most common of all error pages. Create the page for each message as you would a normal page. Design it as you have designed the rest of your site, and include navigation menus so lost visitors can easily get back in to your site.

Also ask visitors to notify you of the error they have received. This can be done by providing an email address link, and allows you to quickly stamp out errors.

Remember - custom error pages can include anything your average HTML page would, including SSI calls, as the error page you're creating is nothing but a normal HTML page.

Some browsers may cache your error pages. This can result in users seeing an error page even if there's no problem. To get around this, include the following META tags in your error pages to prevent them from being cached:

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="Sun, 1 Jan 12:00:00 GMT">



STEP TWO - UPLOAD THE ERRORS

Upload each custom error onto your server. It's good practice to keep these separate from the rest of your site, so create a specific directory especially for your error pages.



STEP THREE - CREATE THE .HTACCESS FILE

How will the server know to show these new error pages instead of the old ones? That's where our .htaccess file comes in. You will need to create a file called .htaccess containing the following line. If you already have a .htaccess file in your server's HTML root directory, add the line to the existing file:

ErrorDocument 404 http://url.to.your/error/404page.html

...where 404 describes the type of error, and http://url.to.your/error/404page.html is, of course, the URL to your custom error page. Note that the .htaccess file syntax is case sensitive!

To add more custom error pages to your .htaccess file, include them like this:

ErrorDocument 404 http://url.to.your/error/404page.html
ErrorDocument 500 http://url.to.your/error/500page.html

The above examples of error pages can be situated anywhere on the web, even on other servers - all you have to do is provide a valid URL.

Once you have created your .htaccess file, upload it to your web site, using your favourite FTP client, in ASCII mode (not BINARY!).

If your server doesn't allow you to upload .htacess files via FTP, you might need to do it via Telnet. Log in at the Telnet prompt, browse to your HTML root directory, and create/load your .htaccess file using your favourite command line text editor, such as PICO or JPICO. Do this by typing something like:

pico .htaccess

...then type the contents of the .htaccess file in the editor and save, usually by pressing CRTL-X.



STEP FOUR - TEST!

Simulate an error to see if your server presents your new error page to you. To test a 404 error, type in an invalid URL of your site in your browser and see what happens!



TROUBLESHOOTING

Trouble - it's bound to happen. As with anything webby, creating a custom error page could have it's problems. If you're not shown your custom error pages, or are presented with a 500 Internal Server Error for all types of errors, check the following:

* Check the syntax of the .htaccess file - make sure it matches the above example. Remember, .htaccess files are case sensitive.

* Did you upload your .htaccess file in ASCII mode? Make sure you did, and if you didn't - redo it!

* Did you name your .htaccess file correctly? Make sure it's called .htaccess, not for example:
* htaccess
* htaccess.txt
* .htaccess.txt

* Are the paths/URLs to your error pages correct?

If you're still having no luck, try setting the permissions of the .htaccess file to 644. Also, as a last resort, try replacing the spaces in the .htaccess file with tabs.

Copyright 2000 © Web Hosting Sizzle.
Acceptable Use and Service Guideline

Learn More on

 CGI Scripts
 HTML
 MySQL
PHP
Form Mail
IRC
UNIX


Web Glossary
 

Enter a search term or word and press Go!
Web Hosting Sizzle