.htaccess Tutorial - Error Messages
In cases where the web server can not fulfill a request,
it will output a generic error message.
You can customize these using .htaccess.
If you are hosted with us, the control panel can do this for you.
1. Custom Error Messages
The ErrorDocument is used for this purpose, followed by a 3 digit
errorcode and the action to perform.
ErrorDocument 404 /notfound.html
|
|
This example will display web page notfound.html in cases
where the requested document is not found.
If you remove a web page from your site and someone
tries to view it, they would see notfound.html instead.
ErrorDocument 404 http://www.other_site.com/notfound.html
|
|
This redirects such requests to the URL you specify.
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.
Replace the action parts shown in red in the above examples to customize the web server behavior.
2. Other Error Numbers
Other comonly used 3 digit codes are listed below.
401 : Authorization Required
Someones tried to access a password protected area but did not
provide correct user/pass info.
403 : Forbidden
This person is blocked from requesting the document.
500 : Internal Server Error
Usually, this means the cgi script being used crashed.