Any ideas why the following wont work:
Quoteif(mysql_num_rows($result)==0){
header('HTTP/1.1 404 Not Found');
header('Location: /404.php');
die();
}
If I comment out both line in turn it eitgher returns a 404 or does the rediect with a 200.
I want the 404 plus redirect.
I have this in my htaccess also:
ErrorDocument 404 /404.php
Any ideas, php headers are doing my head in
I think you shouldn't redirect if it is a 404, as you are already saying that it isn't found. redirecting would then return a new response (found we hope), which is where it is getting confused. More usual would be to return the 404 error then include the contents of your 404 output, so something more like:
if(mysql_num_rows($result)==0){
header('HTTP/1.1 404 Not Found');
include('my404pagecontent.php');
} else {
// do all your usual output
}
ah - too slow: What Jason said.
>>changing it to include /404.php instead
How, lol. This driving me nuts
hurrah (after a little defining the path)
Thank you both.
If not a silly question, why not "HTTP/1.1 301 Moved Permanently" and redirect to homepage (or other preferred page) rather than give a 404?
If your site can't give a 404, it can't be trusted, because its a bottomless pit. Googlebot especially is programmed to deliberately ask for broken URLs just to check a 404 can be gathered. If it can't, it throttles the spidering to a level that seriously hurts.
I have a fear of doing that BK. That's why I always check for real 404s and only do case by case 301s