Trapping Error: There are five kinds of errors that one website can experience. These are
1. 400 Error (Bad Request): It means that a request for a URL has been made but the server is not configured or capable of responding to it.
2. 401 Error (Unauthorized Access): It means that a request for a URL is generated but the request failed to authorize itself as per security settings.
3. 403 Error (Forbidden Error): If any URL has been made for non-access and the request tries to access it, this error is generated.
4. 404 Error (Page Not Found): If any request for URL comes to the server which is not available then this error is generated.
5. 500 Error (Internal Server Error): For any internal error the server throws this error message to browser.
The wonder is that by adding a few lines you can get past the error message and can show your own custom error message. For this develop 5 html pages which will be shown in case these errors are generated. And then add these lines to it.
ErrorDocument 400 /400-page.html
ErrorDocument 401 /401-page.html
ErrorDocument 403 /403-page.html
ErrorDocument 404 /404-page.html
ErrorDocument 500 /500-page.html
Mod_Rewrite (Your own friendly URL): Say you have a php page and the url for this is http://www.yourwebsite.com/product.php?p =cell_phone . Now ?p=cell_phone is the query string and the requested product.php page gets the value and fetches data from database using php script using the parameter. This kind of URL is not indexed by google properly. Don't worry, you can customize very easily using htaccess file. Add the following line in htaccess file and rename the link as cell_phone_product.html.
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^(
Now the first part ^(
I can give you one more example which is just amazing. If any user accidentally types http://yourdomainname.com , it automatically converts it into http://www.yourdomainname.com. And the script is
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^yourdomainname.com [NC]
RewriteRule ^(.*)$ http://www. yourdomainname.com/$1 [L,R=301]
RewriteRule ^(
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
Script execution time: Say one of your script files takes much time to execute. And before it finishes the execution the browser gets disconnected. In that case you can add this statement to increase or control the execution time.
php_value max_execution_time 7200
The fact is that, you can change any php settings with the above statement. The syntax is php_value %Settings_name% %settings_value%.
I wish to come up with more articles on Apache, PHP and MySQL in days to come. Till then happy learning!!
Published by Kanquona Bhattacharjee
A post graduate degree holder (MA) in english from the University of Calcutta. Started career as a freelance author and journalist. View profile
- How to Customize PHP Flag Settings Without Using Apache and Htaccess
- PHP Auction - Working with the Configuration
- PHP: Getting Text to Display from ODBC Database
- PHP Object Oriented Programming OOP for Beginners
- How to Produce Good and Resource-friendly PHP Code
- The Seven Wonders of the Ancient World
- New Seven Wonders: Do You Agree?



