.htaccess
Posted by: Millar (---.server.ntli.net)
Date: June 18, 2006 10:59AM

I can't get .htaccess to work, I changed httpd.conf uncomented LoadModule rewrite_module modules/mod_rewrite.so .

It still wont work, I get a 500 internal server error. I had restarted the server since the edit. This is the contents of my .htaccess file:

ErrorDocument 400 /error.php?error=You made a bad request, the server could not understand it.
ErrorDocument 401 /error.php?error=Authoriation is required to access this page.
ErrorDocument 402 /error.php?error=Payment is required to access this page.
ErrorDocument 403 /error.php?error=The page you requested is forbidden and you cannot view it.
ErrorDocument 404 /error.php?error=The page you requested could not be found.
ErrorDocument 405 /error.php?error=That method is not allowed.
ErrorDocument 406 /error.php?error=That encoding is not acceptable.
ErrorDocument 407 /error.php?error=You need to authenticate your proxy before you can access the page.
ErrorDocument 408 /error.php?error=The request to the page timed out.
ErrorDocument 409 /error.php?error=Another request conflicted with your current one.
ErrorDocument 410 /error.php?error=The page you requested has gone.
ErrorDocument 411 /error.php?error=Content length is required.
ErrorDocument 412 /error.php?error=The precondition failed.
ErrorDocument 413 /error.php?error=Request entity is too long.
ErrorDocument 414 /error.php?error=Request URI is too long.
ErrorDocument 415 /error.php?error=The media type you requested is not supported on this server.
ErrorDocument 500 /error.php?error=There was an internal server error.
ErrorDocument 501 /error.php?error=Not implemented.
ErrorDocument 502 /error.php?error=Bad Gateway.
ErrorDocument 503 /error.php?error=The service you requested is unavailable.
ErrorDocument 504 /error.php?error=The gateway you requested timed-out.
ErrorDocument 505 /error.php?error=The HTTP version is not supported.

Options: ReplyQuote
Re: .htaccess
Posted by: FrankX (---.ipt.aol.com)
Date: June 18, 2006 12:05PM

This page will probably help ...

[httpd.apache.org]

i don't think you have the right content in your .htaccess file.

Luv FrankX



(-> ~ ~ <-)

Options: ReplyQuote
Re: .htaccess
Posted by: CyberSpatium (67.170.181.---)
Date: June 19, 2006 09:33AM

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>"winking smiley;
break;
case 401:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Authoriation is required to access this page.</div>"winking smiley;
break;
case 402:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Payment is required to access this page.</div>"winking smiley;
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>"winking smiley;
break;
case 404:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The page you requested could not be found.</div>"winking smiley;
break;
case 405:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - That method is not allowed.</div>"winking smiley;
break;
case 406:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - That encoding is not acceptable.</div>"winking smiley;
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>"winking smiley;
break;
case 408:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The request to the page timed out.</div>"winking smiley;
break;
case 409:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Another request conflicted with your current one.</div>"winking smiley;
break;
case 410:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The page you requested has gone.</div>"winking smiley;
break;
case 411:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Content length is required.</div>"winking smiley;
break;
case 412:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The precondition failed.</div>"winking smiley;
break;
case 413:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Request entity is too long.</div>"winking smiley;
break;
case 414:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Request URI is too long.</div>"winking smiley;
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>"winking smiley;
break;
case 500:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - There was an internal server error.</div>"winking smiley;
break;
case 501:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Not implemented.</div>"winking smiley;
break;
case 502:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - Bad Gateway.</div>"winking smiley;
break;
case 503:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The service you requested is unavailable.</div>"winking smiley;
break;
case 504:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The gateway you requested timed-out.</div>"winking smiley;
break;
case 505:
echo ("<div align=center><b>There was an error: " . $ApacheErrorCode . "</b><br> - The HTTP version is not supported.</div>"winking smiley;
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.

Options: ReplyQuote


Sorry, only registered users may post in this forum.