Web domain - the script will e-mail the administrator and he
Tuesday, August 21st, 2007the script will e-mail the administrator and he or she can in turn check to see whether this was a valid request and there is something wrong with the page or server, or whether someone was just looking for pages or trying to sniff around where they weren t supposed to be. Apache s ErrorDocument Directive Error handling is an invaluable resource and a must have for Web developers to keep their sites up and running with the fewest end-user problems or complaints. If you rely on people contacting you to tell you about errors on your site, you will never get any decent input. Allowing the server to do this for you will greatly increase your success at running a smooth server. This section first looks at Apache s ErrorDocument method of error handling. Try It Out Using Apache s ErrorDocument Method First of all, you need to make some changes to the httpd.conf file to allow you to create a custom error page. Apache is usually set up by default to go to its own internal error pages, but you don t want that. You want Apache to go to your custom error page, no matter what error has occurred. To do this, you change the default settings to your own specific settings by following these steps: 1. Open up your httpd.conf file, and around line 750 or so, you will find some lines that look like this (if you do not have access to httpd.conf, the following can usually be added to a .htaccess file in the base directory of your Web site): # Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 The server made a boo boo. #ErrorDocument 404 /missing.html #ErrorDocument 404 /cgi-bin/missing_handler.pl #ErrorDocument 402 http://www.example.com/subscription_info.html 2. Change that information to the following, then restart Apache: # Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: ErrorDocument 400 /error.php?400 ErrorDocument 401 /error.php?401 ErrorDocument 403 /error.php?403 ErrorDocument 404 /error.php?404 ErrorDocument 500 /error.php?500 How It Works You have just edited Apache s configuration file to help you with error handling. By using the ErrorDocument directive, you are able to send users to specific error pages depending on what error the server has encountered. For example, if you receive a 404 error, the typical Page Cannot Be Found page, you can redirect it to a page you have created to look like your Web site but still get the 252 Chapter 9
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.