Wizard Creek Consulting

Website Construction - Error Processing

Websites get errors. The most common error is the 404 not found error when someone enters the wrong webpage name.

The following is one approach to dealing with those errors.

Add Error Processing to your htaccess file.

ErrorDocument 400 /error-page.php?400
ErrorDocument 401 /error-page.php?401
ErrorDocument 403 /error-page.php?403
ErrorDocument 404 /error-page.php?404
ErrorDocument 500 /error-page.php?500

Create the error-page.php program.

<html>
<head>
<title>error-page</title>
</head>
<body>
<h1>Error</h1>

<?php>

$error = getenv(QUERY_STRING);

switch ($error) {
    case "400" : $error_msg = "Bad Request"; break;
    case "401" : $error_msg = "Authorization Required"; break;
    case "403" : $error_msg = "Forbidden"; break;
    case "404" : $error_msg = "Not Found"; break;
    case "500" : $error_msg = "Internal Server Error"; break;
    default : $error_msg = "Unknown Error"; break;
}
echo 'Error: ' . $error . ' ' . $error_msg;
?>

<p><a href="http://www.your-domain-name.com/index.htm">
Go to Home Page</a></p>
</body>
</html>

Results

The results will look like the following. The assumption is that everyone will add HTML code to make it look more exciting or interesting.

Error

Error: 404 Not Found

Go to Home Page

Example

Follow the link to see one example:
http://www.wizard-creek.com/this-is-not-a-good-file-name

Wizard Creek Consulting
Wizard Creek Consulting
225 Camelback Road #252 | Pleasant Hill, CA 94523
les.bain@wizard-creek.com | (925) 209-9483
Copyright 2003 - 2017 Wizard Creek Consulting - All Rights Reserved

Serving clients worldwide on the Internet and locally in California.
East Bay, Contra Costa County, Pleasant Hill, Concord, Martinez,
Walnut Creek, Alamo, Danville, San Ramon, Berkeley, Oakland, and San Francisco

Industrial Wheel
Photos by Alex Bain.
Photo by
Alex Bain
Custom Search

Search Wizard Creek Sites