#42969 [Com]: header("Location:") changing HTTP status

From: Date: Thu, 18 Oct 2007 02:04:13 +0000
Subject: #42969 [Com]: header("Location:") changing HTTP status
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118646@lists.php.net to get a copy of this message
ID: 42969 Comment by: carsten_sttgt at gmx dot de Reported By: gustav at cst dot co dot za Status: Open Bug Type: HTTP related Operating System: Windows Server 2003 PHP Version: 5.2.4 New Comment: According to the PHP manual for header(), you want use: | header('Location: http://www.example.com/', true, 303); Regards, Carsten Previous Comments: ------------------------------------------------------------------------ [2007-10-15 09:24:14] gustav at cst dot co dot za Description: ------------ This bug is identical to bug #25044. When a form is posted to a PHP script, and that script wants to forward the browser to another page, the correct HTTP response header code is 303. But, when setting the "Location" HTTP header using the header() function, PHP automatically changes the HTTP response status to "302 Found". This is important because some mobile browsers (Specifically Motorola V360 and Nokia 6310i) will *not* immediately redirect a script that received a post when the code is 302, but *will* when the code is 303. I have recreated this problem on both IIS 6 and Apache. NOTE: The suggested workarounds in bug #25044 do *not* work. Reproduce code: --------------- <?php header('Status: 303 See Other'); header('Location: http://www.example.com/'); die(); ?> ---OR--- <?php header('HTTP/1.1 303 See Other'); header('Location: http://www.example.com/'); die(); ?> Expected result: ---------------- HTTP/1.1 303 See Other Location: http://www.example.com/ Actual result: -------------- HTTP/1.0 302 Moved Location: http://www.example.com/ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42969&edit=1

« previous php.bugs (#118646) next »