Re: causing HTTP error status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
> on the headers you generate in your PHP script. These
> headers are just going to go to the browser. If you
> want to display the error page, you'll have to make your
> PHP script include/readfile() it.

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");
    ?>

   Note: The HTTP status header line will always be the first sent to
   the client, regardless of the actual header() call being the first
   or not. The status may be overridden by calling header() with a
   new status line at any time unless the HTTP headers have already
   been sent.

The only other meaning I can attribute to the first paragraph is that
it is suggesting that a PHP script acting as an error document will
have to do this to set the error code... but I'm not sure that's right
because Apache will already have set the error code.



Nic

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux