If you’re running a LAMP server of basically just a Linux server/Apache server/Parallel server, it should come with a control access for you to be able to write out some scripting codes that can actually run some functions on the server. Normally each server has it’s own default error documents which pops up once an error is committed.
Such as a 404 Error popping out when you type an incorrect URL on your browser. E.g www.yourweb.com/control → Correct, but instead you type: www.yourweb.com/conrtol → wrong. These are some of the mistakes that can pop up an error document. To effectively use the code below, make sure that the size exceeds more than 512bytes, because on IE, if the size of the .htaccess file doesn’t exceed that amount of bytes above, IE will show it’s own error document instead of your custom error pages.
###################################
##
## HTACCESS CONTROL MODULE
## USED TO REDIRECT/DYNAMICALLY
## CONTROL URL's ON A WEBSITE
## ADD AS MUCH COMMENT HERE TO
## MAKE THIS FILE LARGER THAN 512BYTE
###################################
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]
# custom error documents
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
ErrorDocument 500 /500.php
Remember to save your file name as “.htaccess” and upload to your server.place the .htaccess together with the custom Error documents that you’ve designed to suite your need in the same root folder or If it’s not in the same root folder, you can specify it by adding the link in the .htaccess file appropriately. E.g
# see how i've added a directory to the error document
ErrorDocument 404 /errorpage/404.php
ErrorDocument 403 /errorpage/403.php
ErrorDocument 500 /errorpage/500.php
The Error documents that should be created, depends solely on the number of error document you want your users to see once an error occurs.
Example: Error documents can be created with any extension, in this case, am using (dot*PHP) extension as you can see in the example above. Doing this will eventually pop out your very own custom error page once an error is encounter on your Server.
Pingback: Customerror web | Seifen