Customize Error Pages

Creating custom error very useful feather of htaccess file. it gives deliver sensible message to our visitor.we can achieve it by following ways.

1:Change the default error message

2:Redirect to a script

3:Redirect to an external URL

Change the default error message

We can simply change default error message to something more meaningful message.

# htaccess custom error messages ErrorDocument 400 "Bad Request.. ErrorDocument 401 "Speak friend and enter .. ErrorDocument 403 "Forbidden ... ErrorDocument 404 "Not Found ... ErrorDocument 500 "Server is not responding ..

Redirect to a script

We can also write script for error message. and redirect visitor to your error pages like so.

# htaccess custom error scripts ErrorDocument 400 /errors/redirection.php ErrorDocument 401 /errors/authentication.php ErrorDocument 403 /errors/explanation.php ErrorDocument 404 /errors/not_found.pl ErrorDocument 500 /errors/server_error.pl

Redirect to an external url

It is not necessary that your custom error pages do not need to be located on the same domain.you can also redirect visitor to other domain .

# htaccess custom error redirects ErrorDocument 400 http://mydomain.com/400_error.html ErrorDocument 401 http://mydomain.com/401_error.html ErrorDocument 403 http://mydomain.com/403_error.html ErrorDocument 404 http://mydomain.com/404_error.html ErrorDocument 500 http://mydomain.com/500_error.html

Note: To enjoy your custom error pages for IE user, they need to exceed 512 bytes in size.

HTTP Error Codes

Code Description
400 Forbidden
403 1
404 Not Found
405 Method Not Allowed
406 Not Acceptable
408 Request Time-out
409 Conflict
410 Gone
500 Internal Server Error