Nic wrote:
"Richard Lynch" <ceo@xxxxxxxxx> writes:
On Fri, May 5, 2006 5:01 am, Nic wrote:
Hi Rabin
"Rabin Vincent" <rabin@xxxxxx> writes:
On 5/5/06, Nic <nferrier@xxxxxxxxxxxxxxxxxxxx> wrote:
But /mydir/some.php doing:
header("HTTP/1.1 404 Rubbish!!!")
_never_ causes the error document to be picked up.
That's right. Apache's not going to take action based
mod_perl and mod_python can both do this. As can CGIs. So I'll be
really surprised if this isn't possible with PHP.
It's strange because the docs say this can be done; I can't find an
example that is purported to work outside of the docs though.
Where do the docs say this? I can't find it in
http://php.net/header.
The url is:
http://www.php.net/manual/en/function.header.php
The relevant bit is where it says:
There are two special-case header calls. The first is a header that
starts with the string "HTTP/" (case is not significant), which
will be used to figure out the HTTP status code to send. For
example, if you have configured Apache to use a PHP script to
handle requests for missing files (using the ErrorDocument
directive), you may want to make sure that your script generates
the proper status code.
<?php
header("HTTP/1.0 404 Not Found");
?>
I gotta go with Nic on this...
Either I'm being really obtuse, or it just plain don't work right.
Consider this minimalist example:
http://l-i-e.com/404/test.php
http://l-i-e.com/404/index.htm
The 404 header is being completely ignored, afaict
I tried adding "exit;" right after the header, and my browser just
goes way long time and then times out.
I tried HTTP/1.1 and that made no difference.
I'd suggest checking http://bugs.php.net and filing a bug report if
it's not a known issue...
Unless somebody can point out something wrong in our logic.
I think this got cleared up.
Setting the response code (to 404 or 500) is available so that when a
PHP _is_ an error page it can set the code correctly; eg:
apache config:
<Directory /someplace>
ErrorDocument 404 /somplace/error.php
</Directory>
/someplace/error.php
<?php
header("HTTP/1.1 404 Not Found");
echo "<html><body><h1>Sorry, the page you wanted wasn't found.</h1></body></html>";
?>
But I'm still schocked that PHP can't cause the Apache error page to
be served. It seems such a basic thing and all the other web
environments I know (even apache + servlets) allow this.
Ah well.
Nic
Wild Guess here but isnt it because apache defines within its config the
error pages before it defines .php as a usable proccess?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php