Re: causing HTTP error status
| From: | M. Sokolewicz | Date: | Fri, 05 May 2006 10:21:47 +0000 |
| Subject: | Re: causing HTTP error status | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235626@lists.php.net to get a copy of this message | ||
Nic wrote:
Hi Rabin "Rabin Vincent" <rabin@rab.in> writes:The meaning of the paragraph is indeed your "only other meaning I can attribute to it". And no, Apache does not automatically set it (ok, not *always*... there's a lot of magic going on behind the screens).On 5/5/06, Nic <nferrier@tapsellferrier.co.uk> wrote: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.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.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.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.<?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