php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21004 Header Location Fails
Submitted: 2002-12-13 19:12 UTC Modified: 2002-12-16 05:05 UTC
From: tom at minnesota dot com Assigned:
Status: Not a bug Package: HTTP related
PHP Version: 4CVS-2002-12-13 (stable) OS: NetBSD/Alpha (64bit) - 1.6
Private report: No CVE-ID: None
 [2002-12-13 19:12 UTC] tom at minnesota dot com
RE: Bug #19754 shouldn't be closed because CVS-2002-12-13 still exihibit this problem.

index.php:

<?php
$location = "Location: http://".$_SERVER['HTTP_HOST'];
$location.= dirname($_SERVER['PHP_SELF'])."/"."index2.php";
header($location);
?>

---

index2.php:

<?php
echo "<p>You have been redirected</p>";
?>

---

calling index.php should redir to index2.php and echo out:

  You have been redirected

Instead both Mozzila 1.2b and IE 6.x show a blank page. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-14 04:11 UTC] sniper@php.net
Does it redirect though?
What does 'lynx -dump -head <url to the index.php>' output?

Maybe IE6 and Mozilla 1.2b are more strict about the path?
Since your example adds one extra / in the url..

 [2002-12-14 12:19 UTC] tom at minnesota dot com
I don't think it's directing at all. FYI, works fine under PHP-4.2.2, but not CVS.

Using 4.3-CVS
-------------
# lynx -dump -head http://www.minnesota.com/~tom/php/redir/index.php
HTTP/1.1 500 Internal Server Error
Date: Sat, 14 Dec 2002 18:13:20 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.0-dev
X-Powered-By: PHP/4.3.0-dev
Location: http://www.minnesota.com/~tom/php/redir/index2.php
Connection: close
Content-Type: text/html

Using 4.2.2
-----------
# lynx -dump -head http://www.minnesota.com/~tom/php/redir/index.php
HTTP/1.1 302 Found
Date: Sat, 14 Dec 2002 18:17:29 GMT
Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.6g PHP/4.2.2
X-Powered-By: PHP/4.2.2
Location: http://www.minnesota.com/~tom/php/redir/index2.php
Connection: close
Content-Type: text/html

---

In this case I don't think it's Mozilla or IE.
 [2002-12-15 03:51 UTC] sniper@php.net
And how is PHP installed there? DSO or CGI?
What does Apache logs have to say about that internal
error you're getting?

 [2002-12-15 11:39 UTC] tom at minnesota dot com
I tested this on a DSO. There was no error from apache in the log when accessing index.php.
 [2002-12-15 16:16 UTC] sniper@php.net
So it works now?

 [2002-12-15 17:02 UTC] tom at minnesota dot com
No it doesn't work now. If you click on the URL I typed earlier from Minnesota.com, it's running PHP-4.2.2 not PHP-4.3-CVS. Per my other message, redir works fine in 4.2.2 but NOT in 4.3-cvs. I only switch to 4.3-cvs to do the tests, after which, I switch back to 4.2.2. 

header("Location: ....") *DOES NOT* work in 4.3-cvs.
 [2002-12-15 20:27 UTC] sniper@php.net
I'm unable to reproduce this with 4.3.0-dev.


 [2002-12-15 22:55 UTC] tom at minnesota dot com
is 4.3-dev the same as 4CVS-2002-12-13 (stable)? Cause I used the snap from stable branch.
 [2002-12-16 00:23 UTC] tom at minnesota dot com
I wiped the slate clean and fetched another snap. Then started a fresh compile. This time I noticed that I had patched (and forgot that I did when I reported the bug) the previous snap source to fix the unaligned access errors, due to 64-bit integers (see Bug #20994). The patch provided in Bug #20994 fixed the unaligned access problem but caused header() to fail.

The header() function was patched in that patch file provided in Bug #20994.

Please close this bug. My apologies for any time wasted. I've also noted in Bug #20994 that it will break header() function.
 [2002-12-16 05:05 UTC] sniper@php.net
as bogus as it can get..

 [2003-01-30 05:46 UTC] jot at mac dot com
Hello,

I have the same problem. Using Apache 2.0.43 and php-4.3.0-Win32. All my header locations return a blank page. 

It works just fine with my apache/php os X setup, however I need to deploy this on a windows machine.

Any idea on a fix? Is there a build version I should grab instead?

Thank You. And thanks ALOT for PHP. I am actually starting to use it instead of webobjects.

Jot
 [2003-04-25 03:18 UTC] sfelix at labeltechnologies dot com
I have the same problem. My scripts worked fine on php 4.2.2, but since I the 4.3.0 release, it doesn't work anymore. I use win2000, iis5.
The header('Location: blah') returns a header with http code 302 -> moved, but the url I try to redirect to isn't in the header.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC