From: alisencer at gmail dot com Operating system: FreeBSD PHP version: 5.1.2 PHP Bug Type: CGI related Bug description: Location header results in duplicate Status header ([f]cgi only)
Description: ------------ In php-fastcgi, a header("Location: ..") call always results in an additional "Status:" header. This causes the web server to throw a 500 Internal server error. Identical code works perfectly in mod_php. The problem is specific to fastcgi. It doesn't matter what Status code the first header() call sends; the "Location:" call always adds a second "Status: 302" line. The effect is, that it becomes impossible to use header("Location;..."), if at any previous point in the script a Status header has been sent. It is also contrary to what the documentation says: http://de.php.net/manual/en/function.header.php "The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless some 3xx status code has already been set." (Note the last part of that paragraph) Related: This seems to be what was happening in this bug report as well: http://bugs.php.net/bug.php?id=33225 which unfortunately was closed as bogus. Reproduce code: --------------- $ echo "<?php header( 'Status: 301' );header( 'Location: http://www.example.org' );?>" | php/php-fastcgi/php5-fcgi Expected result: ---------------- Content-type: text/html; charset=UTF-8 Status: 301 Location: http://www.example.com Actual result: -------------- Status: 302 Content-type: text/html; charset=UTF-8 Status: 301 Location: http://www.example.com -- Edit bug report at http://bugs.php.net/?id=36705&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36705&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36705&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36705&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36705&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36705&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36705&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36705&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36705&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36705&r=support Expected behavior: http://bugs.php.net/fix.php?id=36705&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36705&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36705&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36705&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36705&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36705&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36705&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36705&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36705&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36705&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36705&r=mysqlcfg