|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-10-15 09:24 UTC] 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/ PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
According to the PHP manual for header(), you want use: | header('Location: http://www.example.com/', true, 303); Regards, Carsten> If it works on your setup, I'd be very interested in finding out > how/why. Have you tested it? Sure: | C:\php>php -v | PHP 5.2.4 (cli) (built: Aug 30 2007 07:06:31) | | C:\php>type C:\www\htdocs\test.php | <?php header('Location: http://www.example.com/', true, 303); ?> | | C:\php>GET -S -m head http://localhost/test.php | HEAD http://localhost/test.php --> 303 See Other | HEAD http://www.example.com/ --> 200 OK | Connection: close | | | C:\php> Regards, Carsten