Search  
   
Browse by Category
 
Netfirms 24/7 Support .: SITE: DESIGN, PUBLISHING & FTP .: E. Securing Your Website .: How do I construct an .htaccess file for custom error messages?

How do I construct an .htaccess file for custom error messages?

To construct an .htaccess file please follow the instructions below:

CUSTOM ERROR PAGES

1. Using a text editor (eg. Notepad), enter the following (where yourdomain.com is your domain name):

ErrorDocument 404 http://www.yourdomain.com/notfound.html

2. The above example will display the web page "notfound.html" in cases where the requested URL is not found.

If you remove a web page from your site and someone tries to view it, they would see the contents of notfound.html instead.

You can also tell .htaccess to display a text message.

ErrorDocument 404 "No such document here"
Here, the text 'No such document here' is shown.

OTHER ERROR NUMBERS

Other commonly used 3 digit codes are listed below.

401 : Authorization Required

Someone has tried to access a password protected area but did not provide correct user/password info.

403 : Forbidden

This person is blocked from requesting the document.

500 : Internal Server Error

Usually, this means the CGI script being used crashed.

TIP: You can configure .htaccess to redirect a visitor visiting a non-existing asp page to a custom error page as long as your hosting plan supports Windows hosting (eg. Business hosting plans and higher). Since our webservers are Windows aware, it tries to process the asp script before making a determination whether the asp file exists or not. As such, using htaccess will not work to redirect them to a custom error page because it will simply err with Service Unavailable (on ADV plan, ASP is not supported). That is, the redirection will not work if the (asp) file does not exist. However if on a plan with Windows support the redirection will work with the following similar coding in .htaccess file:

RewriteEngine on
RewriteBase /
RewriteRule ^([a-z]+).asp$ /directory/customerrorpage.html [R,NC,L]


Note:
Once your .htaccess file has been created you may upload it to the remote server via FTP. Please ensure that the .htaccess is uploaded in ASCII mode if your are using an FTP client such as filezilla or wsftp.

How helpful was this article to you?


.: Powered by Lore 1.5.6
Visit Netfirms.com Web Hosting | Copyright © 1998 - 2009 Netfirms, Inc. All Rights Reserved.