Website Tips


Sunday, 06 October 2013 15:31

HTML Error page

Written by 
Rate this item
(0 votes)

Custom HTML Error Page

The error page is as important as the rest of your website.
The problem is most do not know how to deal with it.

There are a list of errors that covers anything that can go wrong.
But most web designers and web site owners ignore it .
The examples given by almost all show that you need create a page for each error.
This is not correct!

Here I will show you how to have a single HTML error page that covers all errors.

First we need to create the basic html page.
To start place this code at the top of the page.

<html>
<!--#set var=e value="t" -->
<!--#set var=400t value="400 Bad Request" -->
<!--#set var=400 value="400 Error The file you requested is top secret!" -->
<!--#set var=401t value="401 Authorization Required" -->
<!--#set var=401 value="401 Error You don&acute;t have permission to access this file!" -->
<!--#set var=402t value="402 Payment Required" -->
<!--#set var=402 value="402 Error You can\'t have it free!" -->
<!--#set var=403t value="403 Access Forbidden" -->
<!--#set var=403 value="403 Error You are forbidden to to access this!" -->
<!--#set var=404t value="404 File Not Found" -->
<!--#set var=404 value="404 Error The file you requested does not exist on this server!" -->
<!--#set var=405t value="405 Method Not Allowed" -->
<!--#set var=405 value="405 Error The page you requested is using a method not allowed on this server!" -->
<!--#set var=406t value="406 Not Acceptable" -->
<!--#set var=406 value="406 Error The file requested or file type is not acceptable on this server!" -->
<!--#set var=407t value="407 Proxy Authentication Required" -->
<!--#set var=407 value="407 Error A proxy request to a remote server has failed authentication!" -->
<!--#set var=408t value="408 Request Timeout" -->
<!--#set var=408 value="408 Error A timeout occured as there maybe a problem with the page you are trying to access!" -->
<!--#set var=409t value="409 Conflict" -->
<!--#set var=409 value="409 Error A conflict has occured!" -->
<!--#set var=410t value="410 Gone" -->
<!--#set var=410 value="410 Error That resource no longer exists on this server!" -->
<!--#set var=411t value="411 Length Required" -->
<!--#set var=411 value="411 Error Your response failed to provide a lenght!" -->
<!--#set var=412t value="412 Precondition Failed" -->
<!--#set var=412 value="412 Error A condition prior to the response submitted has failed!" -->
<!--#set var=413t value="413 Request Entity Too Large" -->
<!--#set var=413 value="413 Error The file you sent is larger than the max size allowed on this server!" -->
<!--#set var=414t value="414 Request-URI Too Large" -->
<!--#set var=414 value="414 Error The info you requested has generated a line that is beyond the limits of a URL!" -->
<!--#set var=415t value="415 Unsupported Media Type" -->
<!--#set var=415 value="415 Error The file you requested is not supported on this server!" -->
<!--#set var=416t value="416 Request Range Not Satisfiable" -->
<!--#set var=416 value="416 Error The file you requested is not as specified!" -->
<!--#set var=417t value="417 Expectation Failed" -->
<!--#set var=417 value="417 Error What you requested can not be met by this server!" -->
<!--#set var=422t value="422 Unprocessable Entity" -->
<!--#set var=422 value="422 Error You requested was well formed but could not be processed!" -->
<!--#set var=423t value="423 Locked" -->
<!--#set var=423 value="423 Error The file you requested is locked on this server!" -->
<!--#set var=424t value="424 Failed Dependency" -->
<!--#set var=424 value="424 Error The file you requested is in part locked on this server!" -->
<!--#set var=500t value="500 Internal Server Error" -->
<!--#set var=500 value="500 Error The page you requested has caused a Server Error!" -->
<!--#set var=501t value="501 Not Implemented" -->
<!--#set var=501 value="501 Error The request you made is not understood or supported by this Server!" -->
<!--#set var=502t value="502 Bad Gateway" -->
<!--#set var=502 value="502 Error The request has caused a remote Server Error!" -->
<!--#set var=503t value="503 Service Unavailable" -->
<!--#set var=503 value="503 Error The Server is under stress or maintenance and can not complete your request at this time!" -->
<!--#set var=504t value="504 Gateway Timeout" -->
<!--#set var=504 value="504 Error The request has timed out at the remote Server!" -->
<!--#set var=505t value="505 HTTP Version Not Supported" -->
<!--#set var=505 value="505 Error The HTTP version requested by your browser is not supported on this Server!" -->
<!--#set var=506t value="506 Variant Also Negotiates" -->
<!--#set var=506 value="506 Error The resource you requested has caused a circular reference!" -->
<!--#set var=507t value="507 Insufficient Storage" -->
<!--#set var=507 value="507 Error The Server does not have the space required to complete your request!" -->
<!--#set var=510t value="510 Not Extended" -->
<!--#set var=510 value="510 Error The bandwidth has been or soon will be exceeded on this Server!" -->
<!--#set var=etitle value="$REDIRECT_STATUS$e" -->

Next we add the page title

<header>
<title> <!--#echo var="$etitle" --> Error!</title>
</header>

Last we add the error messages

<body>

<h1><!--#echo var="$etitle" --></h1>
        <p><!--#echo var="$REDIRECT_STATUS" --></p>
</body>
</html>

And that's it !!
Now name the file error.shtml

Why .shtml - well this is in case you wish to add a header and footer include.
For instance you can put:

<!--#include Virtual="/includes/header.html" -->
<!--#include Virtual="/includes/footer.html" -->

If you use includes you need to create the files you wish to include.
You can add your header and footer so as to make the page be identical in look to your website. I will add a PHP version that can be downloaded which will work just as well.

The last step is to add the code to your .htaccess file to let your server know that for each error we open this file error.shtml. If you don't have a .htaccess file create one and put the following code in it.

# 400 - Bad Request
ErrorDocument 400 /error.shtml

# 401 - Unauthorized
ErrorDocument 401 /error.shtml

# 402 - Payment Required
ErrorDocument 402 /error.shtml

# 403 - Forbidden
ErrorDocument 403 /error.shtml

# 404 - Not Found
ErrorDocument 404 /error.shtml

# 405 - Method Not Allowed
ErrorDocument 405 /error.shtml

# 406 - Not Acceptable
ErrorDocument 406 /error.shtml

# 407 - Proxy Authentication Required
ErrorDocument 407 /error.shtml

# 408 - Request Timeout
ErrorDocument 408 /error.shtml

# 409 - Conflict
ErrorDocument 409 /error.shtml

# 410 - Gone
ErrorDocument 410 /error.shtml

# 411 - Length Required
ErrorDocument 411 /error.shtml

# 412 - Precondition Failed
ErrorDocument 412 /error.shtml

# 413 - Request Entity Too Large
ErrorDocument 413 /error.shtml

# 414 - Request-URI Too Large
ErrorDocument 414 /error.shtml

# 415 - Unsupported Media Type
ErrorDocument 415 /error.shtml

# 416 - Request Range Not Satisfiable
ErrorDocument 416 /error.shtml

# 417 - Expectation Failed
ErrorDocument 417 /error.shtml

# 422 - Unprocessable Entity
ErrorDocument 422 /error.shtml

# 423 - Locked
ErrorDocument 423 /error.shtml

# 424 - Failed Dependency
ErrorDocument 424 /error.shtml

# 500 - Internal Server Error
ErrorDocument 500 /error.shtml

# 501 - Not Implemented
ErrorDocument 501 /error.shtml

# 502 - Bad Gateway
ErrorDocument 502 /error.shtml

# 503 - Service Unavailable
ErrorDocument 503 /error.shtml

# 504 - Gateway Timeout
ErrorDocument 504 /error.shtml

# 505 - HTTP Version Not Supported
ErrorDocument 505 /error.shtml

# 506 - Variant Also Negotiates
ErrorDocument 506 /error.shtml

# 507 - Insufficient Storage
ErrorDocument 507 /error.shtml

# 510 - Not Extended
ErrorDocument 510 /error.shtml

For windows Servers there is no .htaccess file!
You will need to contact your host to set all errors listed above to the error.shtml file.

Full Example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--#set var=e value="t" -->
<!--#set var=400t value="400 Bad Request" -->
<!--#set var=400 value="400 Error The file you requested is top secret!" -->
<!--#set var=401t value="401 Authorization Required" -->
<!--#set var=401 value="401 Error You don&acute;t have permission to access this file!" -->
<!--#set var=402t value="402 Payment Required" -->
<!--#set var=402 value="402 Error You can\'t have it free!" -->
<!--#set var=403t value="403 Access Forbidden" -->
<!--#set var=403 value="403 Error You are forbidden to to access this!" -->
<!--#set var=404t value="404 File Not Found" -->
<!--#set var=404 value="404 Error The file you requested does not exist on this server!" -->
<!--#set var=405t value="405 Method Not Allowed" -->
<!--#set var=405 value="405 Error The page you requested is using a method not allowed on this server!" -->
<!--#set var=406t value="406 Not Acceptable" -->
<!--#set var=406 value="406 Error The file requested or file type is not acceptable on this server!" -->
<!--#set var=407t value="407 Proxy Authentication Required" -->
<!--#set var=407 value="407 Error A proxy request to a remote server has failed authentication!" -->
<!--#set var=408t value="408 Request Timeout" -->
<!--#set var=408 value="408 Error A timeout occured as there maybe a problem with the page you are trying to access!" -->
<!--#set var=409t value="409 Conflict" -->
<!--#set var=409 value="409 Error A conflict has occured!" -->
<!--#set var=410t value="410 Gone" -->
<!--#set var=410 value="410 Error That resource no longer exists on this server!" -->
<!--#set var=411t value="411 Length Required" -->
<!--#set var=411 value="411 Error Your response failed to provide a lenght!" -->
<!--#set var=412t value="412 Precondition Failed" -->
<!--#set var=412 value="412 Error A condition prior to the response submitted has failed!" -->
<!--#set var=413t value="413 Request Entity Too Large" -->
<!--#set var=413 value="413 Error The file you sent is larger than the max size allowed on this server!" -->
<!--#set var=414t value="414 Request-URI Too Large" -->
<!--#set var=414 value="414 Error The info you requested has generated a line that is beyond the limits of a URL!" -->
<!--#set var=415t value="415 Unsupported Media Type" -->
<!--#set var=415 value="415 Error The file you requested is not supported on this server!" -->
<!--#set var=416t value="416 Request Range Not Satisfiable" -->
<!--#set var=416 value="416 Error The file you requested is not as specified!" -->
<!--#set var=417t value="417 Expectation Failed" -->
<!--#set var=417 value="417 Error What you requested can not be met by this server!" -->
<!--#set var=422t value="422 Unprocessable Entity" -->
<!--#set var=422 value="422 Error You requested was well formed but could not be processed!" -->
<!--#set var=423t value="423 Locked" -->
<!--#set var=423 value="423 Error The file you requested is locked on this server!" -->
<!--#set var=424t value="424 Failed Dependency" -->
<!--#set var=424 value="424 Error The file you requested is in part locked on this server!" -->
<!--#set var=500t value="500 Internal Server Error" -->
<!--#set var=500 value="500 Error The page you requested has caused a Server Error!" -->
<!--#set var=501t value="501 Not Implemented" -->
<!--#set var=501 value="501 Error The request you made is not understood or supported by this Server!" -->
<!--#set var=502t value="502 Bad Gateway" -->
<!--#set var=502 value="502 Error The request has caused a remote Server Error!" -->
<!--#set var=503t value="503 Service Unavailable" -->
<!--#set var=503 value="503 Error The Server is under stress or maintenance and can not complete your request at this time!" -->
<!--#set var=504t value="504 Gateway Timeout" -->
<!--#set var=504 value="504 Error The request has timed out at the remote Server!" -->
<!--#set var=505t value="505 HTTP Version Not Supported" -->
<!--#set var=505 value="505 Error The HTTP version requested by your browser is not supported on this Server!" -->
<!--#set var=506t value="506 Variant Also Negotiates" -->
<!--#set var=506 value="506 Error The resource you requested has caused a circular reference!" -->
<!--#set var=507t value="507 Insufficient Storage" -->
<!--#set var=507 value="507 Error The Server does not have the space required to complete your request!" -->
<!--#set var=510t value="510 Not Extended" -->
<!--#set var=510 value="510 Error The bandwidth has been or soon will be exceeded on this Server!" -->
<!--#set var=etitle value="$REDIRECT_STATUS$e" -->

<!-- Set your Title here -->
<title> - <!--#echo var="$etitle" --> Error!</title>
<!-- Set your Title here -->

<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

</head>
<body bgcolor="#DCDCDC">

<div style="background-color:#ffffff; width:90%; border:#000000 solid 2px;text-align:center;margin: 0 auto;">
<p style="font-weight:bold; font-size:18px">Page Error <!--#echo var=REDIRECT_STATUS --></p>
<p style="font-family:Tahoma, Geneva, sans-serif; font-size:24px; font-weight:bold">You have come here due to some sort of Error</p>
        
        <h1><!--#echo var="$etitle" --></h1>
        <p>&nbsp;</p><!--#echo var="$REDIRECT_STATUS" -->   
      
</div>

</body>

</html>
Read 3449 times Last modified on Wednesday, 09 October 2013 20:20

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.

 

 

Website Tips Search

Registered User