#native_company# #native_desc#
#native_cta#

Redirect Apache error messages to your own Sitemap

By Anders Bjerkholt
on May 25, 2002

Version: 1.01

Type: Sample Code (HOWTO)

Category: Other

License: GNU General Public License

Description: Apache ErrorDocument .htaccess solution

<!--
You want to redirect Apache error messages to your own Sitemap

1.
Include these lines in your .htaccess:

ErrorDocument 401 http://www.yourdomain.com/sitemap.php?error=401
ErrorDocument 403 http://www. yourdomain.com/sitemap.php?error=403
ErrorDocument 404 http://www. yourdomain.com/sitemap.php?error=404


2. In sitemap.php you include this:
-->

<?php
header("Status: 200 OKn"); // This line makes IE5 show this page even if the user has marked for using IE's own errorpage
?>

<HTML><HEAD></HEAD><BODY>
<h1>SITEMAP</h1> 

<?php
if ($error == "401") {
print "<br>";
print "Error ";
print $error;
print ": You have been sent to this page because you failed to provide a valid username and password to access that directory. You may try one of these pages:";
}
if ($error == "403") {
print "<br>";
print "Error ";
print $error;
print ": You have been sent to this page because it is forbidden to access that folder. You may try one of these pages:";
}
if ($error == "404") {
print "<br>";
print "Error ";
print $error;
print ": You have been sent to this page because the page you requested does not exist anymore. You may try one of these pages:";
}
?> 

- ----- All of your links here ---

</BODY></HTML>