I am trying this example forthe ErrorDocument directive. Firstly, i have made the following changes to my “httpd.conf” file.
I have changed this code of the httpd.conf file
Code: Select all
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 “The server made a boo boo.”
#ErrorDocument 404 /missing.html
#ErrorDocument 404 “/cgi-bin/missing_handler.pl”
#ErrorDocument 402 http://www.example.com/subscription_info.html
#
Code: Select all
#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
ErrorDocument 400 /error.php?400
ErrorDocument 401 /error.php?401
ErrorDocument 403 /error.php?403
ErrorDocument 404 /error.php?404
ErrorDocument 500 /error.php?500
Code: Select all
<html>
<head>
<title>Beginning PHP6, Apache, MySQL Web Development Custom Error Page </title>
</head>
<body>
<?php
switch ($_SERVER['QUERY_STRING'])
{
case 400:
echo '<h1> Bad Request </h1>';
echo '<h2> Error Code 400 </h2>';
echo '<p>The browser has made a Bad Request.</p>';
break;
case 401:
echo '<h1> Authorization Required </h1>';
echo '<h2> Error Code 401 </h2>';
echo '<p>You have supplied the wrong information to access a secure resource.</p>';
break;
case 403:
echo '<h1> Access Forbidden </h1>';
echo '<h2> Error Code 403 </h2>';
echo '<p>You have been denied access to this resource.</p>';
break;
case 404:
echo '<h1> Page Not Found </h1>';
echo '<h2> Error Code 404 </h2>';
echo '<p>The page you are looking for cannot be found.</p>';
break;
case 500:
echo '<h1> Internal Server Error </h1>';
echo '<h2> Error Code 500 </h2>';
echo '<p>The server has encountered an internal error.</p>';
break;
default:
echo '<h1> Error Page </h1>';
echo '<p>This is a custom error page...</p>';
}
echo '<p><a href="mailto:sysadmin@example.com">Contact</a> the system administrator if you feel this to be in error.</p>';
?>
</body>
</html>
Code: Select all
Page Not Found
Error Code 404
The page you are looking for cannot be found
Contact the system administrator if you feel this to be in error
Code: Select all
Error Page
This is a custom error page...
Contact the system administrator if you feel this to be in error.