29.11. Setting Up Custom Error Messages

When a browser attempts to access a page that does not exist, a directory that is password protected, or a CGI program that is malfunctioning, Apache returns one of its built-in error messages. Because these error message pages are not always friendly or nice to look at, you can configure the web server to use your own pages instead. This can be set up to apply to all virtual servers, a single server or just one directory. The steps to follow are:

1.
On the module's main page, click on either a virtual server or the Default Server icon if you want to define a custom error message that applies to all servers.

2.
If you only want the custom message to be displayed for requests to a particular directory, URL path, or filename, click on its icon on the server options page. If no icon for the directory exists yet, you will need to define one by following the steps in Section 29.6 “Setting Per-Directory Options”.

3.
Click on the Error Handling icon in the directory or on the virtual server options page.

4.
You can enter error codes and their corresponding custom messages in the Custom error responses table. Any existing error messages for the directory or server will be listed, followed by a blank row. To add a new code, start by entering the HTTP error number into the Error code field. Some of the more common codes and their causes are:

404 – The requested page does not exist.

403 – Access to the page is denied.

401 – The browser must log in first before accessing the page.

500 – A CGI program failed, or some other internal error occurred.

If you just want to change the message that Apache displays when the error occurs, select Show message under the Response column and enter the text of your new message into the field under URL or message.

On the other hand, if you want the contents of another page to be displayed instead, select Goto URL and enter either a URL page (like /errors/500.html) or a full URL (like http://www.error.com/505.html) into the URL or message field. In the latter case, the browser will be redirected to the URL when an error occurs with the chosen code.

5.
Click the Save button at the bottom of the page. If you want to add another custom error message, click on the Error Handing icon again and fill in the new blank row in the table.

6.
Click the Apply Changes button on any page to make the new custom error message active.

Some web browsers, such as IE in its default configuration, will not display the text of error messages sent by the web server. Instead, only the error code number and a more friendly message generated by the browser is displayed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.216.175