back to Welcome Page Web Hosting Plans About our Web Design Services About our Web Promotion Services Our clients web sites Wolf Web Customer Support        
Wolf Web Customer Support   web support
Wolf Web Solutions Customer Support Customer Support
Custom Error Messages

To have custom error messages on your site, just create a file named ".htaccess" in any subdirectory from which you serve web pages. The error messages will apply to that directory and all directories underneath it, and can be overridden by additional .htaccess files in those subdirectories if necessary.

Here is an example .htaccess file:

ErrorDocument 403 /errors/restricted.html
ErrorDocument 404 "Sorry, that file was not found.
ErrorDocument 500 http://www.yourdomain.com/errors/server_error.html

In this particular example:
  • (1) If the user requests a document to which access is not allowed (a 403 error), they will be shown the document "/errors/restricted.html". This will be just as if they requested http://www.yourdomain.com/errors/restricted.html, except the URL they see will be the one they entered, for example, "http://www.yourdomain.com/.htaccess" For this to work, the filename given must be absolute, for example, /errors/restricted.html, and not "errors/restricted.html", as this is actually the trailing part of the URL to be effectively shown. If the "/" is omitted, instead the error would be shown as text, as in the next example.

  • (2) If the user requests a document that does not exist (a 404 error), they will be simply shown the text "Sorry, that file was not found." Note the lack of the trailing quotation mark; this is intentional, as it otherwise will be displayed.

  • (3) If the user requests a document that causes a server error (a 500 error), such as a malfunctioning CGI program, they will be redirected to the URL "http://www.yourdomain.com/errors/server_error.html". This is different from the first example, in that here the browser is actually told to fetch this new document at the given URL, instead of the contents of that URL simply being sent along to the browser with no perceived redirection as in the first example.


Some pointers:
Any error can be redirected to a CGI script instead of a .html file, which could provide detailed information about the error, and also log any pertinent information in a MUCH more detailed manner than Apache does by default. However, Do Not redirect 500 errors to a .CGI script, because if .CGI happens to not be functioning, an endless loop will be created! Remember that any error number can be given any of the types of redirection responses as shown above, but generally the most useful is the first form where the .html file or .cgi program is simply shown in place of the default error message. Be careful not to restrict access to the /errors directory (or whatever directory you place the error messages in), so that strange things don't happen.

Back to Customer Support

I found the information on this page to be:
valuable not very valuable No Answer
Comments


Have a question? Ask Wolf Web!


top of page

[ Home | Hosting | Sign Up | Design | Promotion | Domains |Clients | Web Mail | Support | Resources | Contact | Site Map | Search ]