PDA

View Full Version : need help with a 404 error


godofreality
06-08-2009, 04:04 AM
is there anyway i can send the referring url to my 404 error page using .htaccess and if so how i would i do this...

this is what i have in mind...

ErrorDocument 404 http://www.mysite.net/404.php?referrer={referrer}

schleppel
06-09-2009, 01:58 AM
Just use
ErrorDocument 404 /404.php
and get the referrer in PHP from
$_SERVER['HTTP_REFERER']

If you use a full URL for an ErrorDocument a redirect will occur and the correct (in this case 404) HTTP status will not be sent.
Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code. In addition, if you use a remote URL in an ErrorDocument 401, the client will not know to prompt the user for a password since it will not receive the 401 status code. Therefore, if you use an ErrorDocument 401 directive then it must refer to a local document.

godofreality
06-09-2009, 07:34 AM
yeah just tried that method and it is throwing an error instead of directing me to the 404.php page

schleppel
06-10-2009, 02:07 AM
What error do you get?