Two easy steps are involved in creating your custom http error pages:
- Copy error.php file to your domain's /htdocs directory.
- Edit your /htdocs/.htaccess file and add the lines below.
# each handling the error associated with
# respected code. Find reference at
# http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
# The most common first = not found
ErrorDocument 404 /error.php?e=404
ErrorDocument 400 /error.php?e=400
ErrorDocument 401 /error.php?e=401
ErrorDocument 403 /error.php?e=403
ErrorDocument 405 /error.php?e=405
ErrorDocument 408 /error.php?e=408
ErrorDocument 410 /error.php?e=410
ErrorDocument 411 /error.php?e=411
ErrorDocument 412 /error.php?e=412
ErrorDocument 413 /error.php?e=413
ErrorDocument 414 /error.php?e=414
ErrorDocument 415 /error.php?e=415
ErrorDocument 500 /error.php?e=500
ErrorDocument 501 /error.php?e=501
ErrorDocument 502 /error.php?e=502
ErrorDocument 503 /error.php?e=503
ErrorDocument 506 /error.php?e=506
error.php:
<?php $e = (int)$_GET['e']; $errors[400] = 'Bad Request'; $errors[401] = 'Unauthorized'; $errors[403] = 'Forbidden'; $errors[404] = 'Not Found'; $errors[405] = 'Method Not Allowed'; $errors[408] = 'Request Timeout'; $errors[410] = 'Gone'; $errors[411] = 'Length Required'; $errors[412] = 'Precondition Failed'; $errors[413] = 'Request Entity Too Large'; $errors[414] = 'Request-URI Too Long'; $errors[415] = 'Unsupported Media Type'; $errors[500] = 'Internal Server Error'; $errors[501] = 'Not Implemented'; $errors[502] = 'Bad Gateway'; $errors[503] = 'Service Unavailable'; $errors[504] = 'Variant Also Negotiates'; ?> <html> <meta http-equiv="refresh" content="6;url=/"/> <title>Error!</title> <style type="text/css"> </style> </head> <body> <div> <h1> Error <?php echo "$e: $errors[$e]"; ?> </h1> </div> More info @ http://en.wikipedia.org/wiki/List_of_HTTP_status_codes<br/> Redirecting to main site in 6s... </body> </html>
These example modifications give user notice when error occurs, optionally providing additional information via Wikipedia, and redirect to main page after 6 seconds.


