|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20943 header("HTTP/1.1 nnn xxx") not working under Apache
Submitted: 2002-12-11 11:48 UTC Modified: 2003-01-02 18:45 UTC
Avg. Score:3.5 ± 0.9
Reproduced:8 of 8 (100.0%)
Same Version:3 (37.5%)
Same OS:5 (62.5%)
From: michele dot manzato at verona dot miz dot it Assigned:
Status: No Feedback Package: Output Control
PHP Version: 4.2.3 OS: WIN2K, Apache 1.3.x/2.0.x
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
42 + 26 = ?
Subscribe to this entry?

 [2002-12-11 11:48 UTC] michele dot manzato at verona dot miz dot it
Tried writing this script (PHP 4.2.3, Apache 1.3.x/2.0.x, not tried under IIS):

header("HTTP/1.1 200 OK\r\n");

If PHP is configured as a Module it works fine. If PHP is configured as CGI Apache breaks the output and shows its own "Internal Server Error" page. Apache was installed as out-of-the box, no special options apart PHP/CGI configuration directives. Apache error log line is:

[Wed Dec 11 18:41:38 2002] [error] [client] malformed header from script. Bad header=HTTP/1.1 200 OK: php-cgi.exe

Is this a correct behaviour? My config is broken? Is it a bug for Apache????


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-11 11:55 UTC]
Please try using this CVS snapshot:
For Windows:
 [2002-12-12 03:49 UTC] michele dot manzato at verona dot miz dot it
Yes, by using this distrib it works. Hovever if I run php-cgi.exe from command line I get this output:

Content-type: text/html
X-Powered-By: PHP/4.4.0-dev


so the HTTP header gets stripped. If I change the header in header("HTTP/1.1 500 Server Error") I get this:

Status: 500
Content-type: text/html
X-Powered-By: PHP/4.4.0-dev


thus the HTTP Header is converted to a "Status:" header line. Fine, but shouldn't Apache be able to handle "HTTP/1.1 nnn xxx" as well?

 [2002-12-14 05:19 UTC] phpbugs at startearning dot com

I just spent a while investigating a simular problem to this one:-

header("HTTP/1.0 403 Unauthorized");

Was sending a header through to my machine but it was not prompting my browser to display the correct message (IE & Mozilla)

I also noted that 404's were not working either.

Cutting a long story short I manipulated my headers so they looked simular to a good 404 & came up with the following which now has the correct effect on my browser.

        header("HTTP/1.0 403 Unauthorized");
        header("Connection: Keepalive");
        header("Content-Encoding: Chunked");

My environment is:
Redhat Linux 8.0 
Apache 2.0.40
PHP 4.2.2

I suspect this is an interaction problem between PHP 4.2.x and Apache 2.0.x .

This also started occurring on my home Linux machine after I upgraded to apache 2.0.40 and I fixed it using the same method.

Hope this helps someone
 [2002-12-19 23:33 UTC]
Please try using this CVS snapshot:
For Windows:

You may also want to try a latest Apache 2, many bugs were fixed between 2.0.40 & 2.0.43, which is the current version.
 [2003-01-02 18:45 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

 [2009-05-16 17:35 UTC] kenorb at gmail dot com
The same problem.

PHP-CGI: 5.10-dev (tested with 5.2.8/5.2.9 as well)
OS: Red Hat Enterprise Linux ES release 3 (Taroon Update 9)
Apache: Apache/1.3.33

Not working code:
which cause: 'Internal Server Error' page
header('HTTP/1.1 404 Not Found');
header('Content-Type: text/html; charset=utf-8');
echo 'Not Found';

Working code:
header('Status: 404 Not Found');
header('Content-Type: text/html; charset=utf-8');
echo 'Not Found';

Related to the same PHP bugs: #3884 #11375 #20416 #41661
Any help?
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 06:01:31 2024 UTC