Forum Moderators: phranque
I'm using a customized error script together with
this few lines in .htaccess file:
ErrorDocument 400 /error.php?err=400
ErrorDocument 401 /error.php?err=401
ErrorDocument 403 /error.php?err=403
ErrorDocument 404 /error.php?err=404
ErrorDocument 500 /error.php?err=500
inside the error.php there is a mailfunction (and some filters) and at last this code:
header("HTTP/1.1 ".$error." ".$http_msgs[$error]);
header("Location: ".$redirect_to);
so, first I send the http error back and then I redirect to a part. page (home).
If I check the status for a not existing file than it's a 302. My question is, if google spiders my website, does the crawler get a 404 error?
kind regards
Olaf
You should remove the "Location:" header from the code for the 404 response. If you wish to redirect the visitor, then this should be done by the /error.php?err=404 script *after* the 404 response.
Jim
then this should be done by the /error.php?err=404 script *after* the 404 response.
What do you mean exactly with this? the 404 error is provided by the server and the I send a header with a 404 error and then the redirect is done.
Of course I ask this to do it right for Google ;-)
I tested in the meantime a little bit with this code:
<?php
$fp = fsockopen("www.pefina.nl", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET /sdfsdf.htm HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
If I run this script I get an 404 error... :-S
gr. Olaf
It is imporatant to use a testing method that will show you the handhake between the client and the server one step at time. So the server header checker (they typically don't follow redirects) will show you the 404, and only if you then 'follow' the redirect on that 404 error page will the server header checker show you the 302.
I'd recommend avoiding 302's for now and using a 301 instead, due to Google's demonstrated problem with handling 302s.
Jim
RedirectPermanent /old_file.php?lang=nl&country=BE [domain.nl...]
What I try is a more flexible way with the help of php. Based on the requested file to send diff. headers and redirects to diff. pages. That is to handle 404 and 301 on a diff. way.
by the way, thanks for helping so far.