Hi,
i started PHP with a simple small script to catch server errors. First we need to edit (or create) a .htaccess file in our wwwroot. Fill it with the following
# Customized error messages.
ErrorDocument 404 /error/index.php #change the path to your needs
This will intruct the webserver to call our index.php when an error 404 occours.
Now lets code our index.php
GeSHi (php):
<?php
$TPL_FILE = "error.tpl";
// Get the status 404,403,500... ?
$err = $_SERVER['REDIRECT_STATUS'];
// for debugging reasons uncomment this
// echo phpinfo();
$handle =
fopen($TPL_FILE,
"r");
// Depending on the error, save some errormessages
switch ($err) {
case '404':
$errshort = "error 404: file not found!";
$message = "The requested file could not found on this server!";
break;
case '403';
$errshort = "error 403: forbidden!";
$message = "Access denied - you are not allowed to access this site!";
break;
case '500';
$errshort = "error 500: internal server error!";
$message = "The requested file could not processed by its preprocessor!";
break;
default:
break;
}
// Now replace the above saved messages with its placeholders in the template
// Send a correct header to the browser
// Output of the template
?>
Created by GeSHI 1.0.7.20
Just create a normal HTML file called error.tpl and use the two placeholders for a shortmessage and a long one.
That's it

Save it and try
http://yourdomain/site_does_not_exist and see it works...