How to create a custom 404 error message

Create a customized 404 error message using your .htaccess file.

Server errors are going to occur for one reason or another. Knowing this, you should take the time to create some custom error pages. These pages will not only keep your visitors engaged, but will give them options such as where to go next if the page was moved or didn’t exist.

One of the most common error messages is a 404 error. 404 errors are the result of broken links and mistyped URLs. See below for step-by-step instructions on how to create a customized 404 error message using the .htaccess file on an Apache-based server.

Here’s how you do it on an Apache-based server:

Create a file using any text editor and save it as “.htaccess.txt”

Next, copy and paste the below information into the file and save.

_________________________________________________

< Files .htaccess>
order allow,deny
deny from all
< /Files>

ErrorDocument 401 /errordocs/error401.html

________________________________________________

note: The first part is just for a little security and stops people from viewing your .htaccess file. The second part tells the Apache server to redirect any 404 errors to the file “error404.html”.

That’s it… Your ready to test it.

Upload the new .htaccess file to the root directory of your server.

note: Be sure to remove the .txt extension from the file name. On some servers you might have to set the file permissions for the file. You can do this through the interface in most FTP programs. Set it to : chmod 644

More information on how to set file permissions can be found at: http://en.wikipedia.org/wiki/Permissions

There are several other error documents that you might wish to customize.

400 - Bad request
401 - Authorization Required
403 - Forbidden directory
404 - Page not found
500 - Internal Server Error

For each one you want to use, simply add a line to your .htaccess file and create the corresponding page.

_________________________________________________

< Files .htaccess>
order allow,deny
deny from all
< /Files>

ErrorDocument 400 /errordocs/error400.html
ErrorDocument 401 /errordocs/error401.html
ErrorDocument 403 /errordocs/error403.html
ErrorDocument 404 /errordocs/error404.html
ErrorDocument 500 /errordocs/error500.html
________________________________________________

More information on the types of server error messages can be found at:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
http://www.w3schools.com/tags/ref_httpmessages.asp

del.icio.us:How to create a custom 404 error message   digg:How to create a custom 404 error message   spurl:How to create a custom 404 error message   wists:How to create a custom 404 error message   simpy:How to create a custom 404 error message   newsvine:How to create a custom 404 error message   blinklist:How to create a custom 404 error message   furl:How to create a custom 404 error message   reddit:How to create a custom 404 error message   fark:How to create a custom 404 error message   blogmarks:How to create a custom 404 error message   Y!:How to create a custom 404 error message   smarking:How to create a custom 404 error message   magnolia:How to create a custom 404 error message   segnalo:How to create a custom 404 error message

Related Entries

0 Responses to “How to create a custom 404 error message ”


  1. No Comments

Leave a Reply