php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33266 Response header sent as 302 dispite being set to 301
Submitted: 2005-06-07 23:40 UTC Modified: 2005-06-08 08:56 UTC
From: nkulbiski at ogdenpubs dot com Assigned:
Status: Not a bug Package: IIS related
PHP Version: 5.0.3 OS: windows 2000
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nkulbiski at ogdenpubs dot com
New email:
PHP Version: OS:

 

 [2005-06-07 23:40 UTC] nkulbiski at ogdenpubs dot com
Description:
------------
This should return a response header of 301, but sends a response header of 302.

Reproduce code:
---------------
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: http://{$_SERVER['HTTP_HOST']}/library/{$redirect[0]['full_safe_name']}");
	header("Connection: close");

Expected result:
----------------
I expected a response header of 301 and the page to be redirected to the new url.

Actual result:
--------------
It did redirect to the new url but send a responce header of 302.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-08 00:24 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-06-08 08:56 UTC] rasmus@php.net
The way to do that is not with 2 header calls like that.  Location defaults to a 302 unless you tell it otherwise like this:

  header("Location: http://example.com", true, 301);
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 17:01:28 2025 UTC