|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21637 Header('Location: ... ') problem
Submitted: 2003-01-14 11:20 UTC Modified: 2003-07-20 10:36 UTC
Avg. Score:4.7 ± 0.7
Reproduced:5 of 6 (83.3%)
Same Version:2 (40.0%)
Same OS:4 (80.0%)
From: pthiebaud at labeltechnologies dot com Assigned:
Status: No Feedback Package: IIS related
PHP Version: 4.3.0, 4.3.2dev OS: Windows 2000, WinXP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: pthiebaud at labeltechnologies dot com
New email:
PHP Version: OS:


 [2003-01-14 11:20 UTC] pthiebaud at labeltechnologies dot com
We have a PHP 4.3 installation on Windows 2000 Server & Workstation. On both systems, the following code produce a PHP crash.

    header('Content-type: text/html');
    header('Location: '.$url);

If we remove the "header('Content-type: text/html');" line, the code work fine, but we need to be able to force the Content type header for our application to work.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-14 19:20 UTC]
What do you mean with 'crash' ? Do you get any errors?

 [2003-01-15 08:00 UTC] pthiebaud at labeltechnologies dot com
Actually, there is no error, the system just stalls, we got nothing out as a result and we are forced to kill the inetinfo process to restart PHP (just stopping the service W3SVC wont work, the service wont stopped and will stay in a "stopping" mode). It seems to be a problem between IIS and PHP, but we didn't have this problem up to version 4.2.2. We had another problem with the headers in version 4.2.3 that was reported in bug #19351, maybe it is related?
 [2003-01-15 12:37 UTC]
Which SAPI are you using?
 [2003-01-15 12:49 UTC] pthiebaud at labeltechnologies dot com
php4isapi.dll created friday the 27th of december 2002 at 05:43:24.
We even created a filter at the master properties level of IIS using php4isapi.dll. It used to fix a lot of "memory" problems...
 [2003-01-16 09:30 UTC]
sure, it should not crash or hang, but...

this combination of header fields just makes no sense,
as the actual content-type is determined by the result
of the request to the 'Location:' URL
(right now i can't think of *any* header that would
 make sense in combination with 'Location:')

maybe it is even the webserver itself and not php
that gets confused by this header combination?
did it work with previous PHP versions?
 [2003-01-16 09:50 UTC] pthiebaud at labeltechnologies dot com
It was working fine with PHP up to version 4.2.2 (dont know about 4.2.3 because of our ohter problem with headers cf bug #19351)
 [2003-01-17 10:50 UTC] pthiebaud at labeltechnologies dot com
We did try to remove the "header('Content-type: text/html')" portion of the code. We then have problems with the "print_r" or the "echo" functions that will not work correctly. We receive only part of the page, PHP seems to forget to process some lines of code. If we put back the header line, then the code works perfectly.
 [2003-01-25 08:56 UTC]
you have *output* on a redirect page?

this once again doesn't make sense at all to me ...

(but still it should not hang, esp. if it worked in 4.2.x)

how does IIS handle redirects? does it just pass them to the client or does it handle some of them itself?
 [2003-01-27 02:49 UTC] pthiebaud at labeltechnologies dot com
No, the output is on the result page. Ex: page 1 redirect to page 2 and page 2 echos out "Hello World". In the case we put the "header('Content-type: text/html');" line we do see "Hello world", if we delete that line we don't se "Hello world" (not as simple as this, but you got the idea). By the way we also do an ob_flush to make sure everything is treated, but it doesn't change a thing.
 [2003-04-28 12:13 UTC]
I had a strange problem with IIS and redirects; when output buffering was enabled, a redirecting page (that had some debug output) would show output from the page that it was being redirected to, after its own output.
This needs further investigation :/

 [2003-05-23 13:35 UTC] jonsagara at hotmail dot com
Windows 2k Pro, SP3
PHP 4.3.1, running as CGI

I am experiencing a similar problem.  If I hard-code the redirect page, then it works fine:
header("Location: goto.php");

But if I try to use a variable, INETINFO.EXE crashes (yes, it redirects to itself, but there are different execution paths):
header("Location: " . $_SERVER["SCRIPT_NAME"]);

I have a reproducible case.  Do you want the files?
 [2003-07-20 10:36 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.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 14:01:31 2024 UTC