Subscribe:

Ads 468x60px

Pages

Wednesday, August 10, 2011

Custom Error Page with .htaccess

404 Page Not Found
When you type wrong URL in a address bar for any website then you usually get the following error with the message.
The 404 is error code in http which represents that “file is not found” in the server.
To display your own custom error page:
create a .htaccess file in the root of the web server and place the following code in that file. 
ErrorDocument 404 /errror404.htm

This would cause any error code resulting in 404 to be forwarded to example.com/error404.html.
In the above line ErrorDocument is a server directive and 404 is the server status code and last part is the name of the error page created by yourself.

If you want to create the custom error page for the codes 404 and 400 (bad request) then you can put the two following lines in .htaccess file.
ErrorDocument 404 /errror404.htm
ErrorDocument 400 /errror400.htm


Note : Never try to put a ErrorDocument for code 200 which mean that page is found and causes the infinite loop in the server.

0 comments:

Post a Comment