mod_rewrite has nothing to do with what you are tying to do. mod_rewrite handles apache rewrites directives, not errordocument. Also, you are using the incorrect syntax for errordocument. you cannot use
error=The HTTP version is not supported, because you are using text where apache is expecting an url, and does not work.
I have just coded a custom fix for you. It includes the correct way to use errordocument in your htaccess file, and a custom php script to handle your errors. you can customize the output of my php script to suit your likings. Just note that I have not tested the code so I may have a typo or missing quote. If you have any problems, let me know.
change your htaccess file to:
ErrorDocument 400 "/error.php"
ErrorDocument 401 "/error.php"
ErrorDocument 402 "/error.php"
ErrorDocument 403 "/error.php"
ErrorDocument 404 "/error.php"
ErrorDocument 405 "/error.php"
ErrorDocument 406 "/error.php"
ErrorDocument 407 "/error.php"
ErrorDocument 408 "/error.php"
ErrorDocument 409 "/error.php"
ErrorDocument 410 "/error.php"
ErrorDocument 411 "/error.php"
ErrorDocument 412 "/error.php"
ErrorDocument 413 "/error.php"
ErrorDocument 414 "/error.php"
ErrorDocument 415 "/error.php"
ErrorDocument 500 "/error.php"
ErrorDocument 501 "/error.php"
ErrorDocument 502 "/error.php"
ErrorDocument 503 "/error.php"
ErrorDocument 504 "/error.php"
ErrorDocument 505 "/error.php"
now create a file called error.php and use this code.
<?php
// Copyright 2006 JT Phillips AKA CyberSpatium
// WAMP Forum - www.WAMPSERVER.com
// Feel free to edit my code to suit your tastes.
// use apache_lookup_uri function to perform a partial request for the uri
// and return all info about it
$ApacheErrorArray = apache_lookup_uri($_SERVER['REQUEST_URI']);
// the apache_lookup_uri function returns an object. we need this to be an array
// for this script to work, so we change it to an array.
settype($ApacheErrorArray, 'array');
// Using the status from the apache_lookup_uri funtion, we get the apache error code number we are lookign for.
$ApacheErrorCode = $ApacheErrorArray['status'];
// use a switch statment to loop though and output the correct error code
// and error message.
switch ($ApacheErrorCode) {
case 400:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - You made a bad request, the server could not understand it.</div>"
;
break;
case 401:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Authoriation is required to access this page.</div>"
;
break;
case 402:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Payment is required to access this page.</div>"
;
break;
case 403:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The page you requested is forbidden and you cannot view it.</div>"
;
break;
case 404:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The page you requested could not be found.</div>"
;
break;
case 405:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - That method is not allowed.</div>"
;
break;
case 406:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - That encoding is not acceptable.</div>"
;
break;
case 407:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - You need to authenticate your proxy before you can access the page.</div>"
;
break;
case 408:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The request to the page timed out.</div>"
;
break;
case 409:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Another request conflicted with your current one.</div>"
;
break;
case 410:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The page you requested has gone.</div>"
;
break;
case 411:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Content length is required.</div>"
;
break;
case 412:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The precondition failed.</div>"
;
break;
case 413:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Request entity is too long.</div>"
;
break;
case 414:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Request URI is too long.</div>"
;
break;
case 415:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The media type you requested is not supported on this server.</div>"
;
break;
case 500:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - There was an internal server error.</div>"
;
break;
case 501:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Not implemented.</div>"
;
break;
case 502:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Bad Gateway.</div>"
;
break;
case 503:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The service you requested is unavailable.</div>"
;
break;
case 504:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The gateway you requested timed-out.</div>"
;
break;
case 505:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The HTTP version is not supported.</div>"
;
break;
}
?>
Post Edited (06-19-06 09:36)
CyberSpatium----------------------WAMP Forum Admin
Web Development for Newbie's Blog - Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.