404 Header Problems

From: Date: Wed, 13 Jul 2005 20:01:24 +0000
Subject: 404 Header Problems
Groups: php.general 
Request: Send a blank email to php-general+get-218644@lists.php.net to get a copy of this message
I'm trying to issue a 404 header on one of my pages. But it does not redirect. I figured, with many function calls before it, that it might be outputting something to the screen before the header() command was issued. So, I tried issuing a 404 header from a new page, consisting of this code: <? header("HTTP/1.0 404 Not Found"); exit(); ?> or <? header("HTTP/1.0 404 Not Found"); ?> But neither of these work. Notice how there should also be no ouput to the screen before the header is closed. I've also tried: <? |header("Status: 404 Not Found"); ?> which gives the same results. The results are this: an output of <html><head></head></html>. I'm on a large shared server, and my guess is that when there is a bug with some code in php, the server chooses to ouput this instead of the actual error code(s). I've experienced this many times when I upload a page and there is a simple syntax error such as one semi-colon missing from a statment. This is probably so that the server doesn't get hacked. If I try to issue both commands, in either order, I get this: Not Found The requested URL /cgi-sys/php.cgi/testing_server/404_error.php was not found on this server. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. So....what's going on here? Am I to conclude that the 404 header does not work, and that I should just use a Redirect: header() to my 404 page? Best Regards, Scott Taylor

« previous php.general (#218644) next »