homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Correct status
Am I causing confusion

 10:16 pm on Jun 18, 2003 (gmt 0)

My script reads

header("Location: http://www.mydomain.co.nz/mydir");
header("Status: HTTP/1.1 301 Moved Permanently");

and produces the following headers
Server Response: http://www.mydomain.co.nz
Status: HTTP/1.1 302 Found
Date: Wed, 18 Jun 2003 22:04:36 GMT
Server: Apache/1.3.27 (Unix) mod_log_bytes/1.2 mod_bwlimited/1.0 PHP/4.3.1 FrontPage/ mod_ssl/2.8.14 OpenSSL/0.9.6b
X-Powered-By: PHP/4.3.1
Status: HTTP/1.1 301 Moved Permanently
Location: http://www.mydomain.co.nz/mydir
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

Does the repeated status cause confusion? And is there a way of suppressing the first status. I want to use this technique sith a tracking script.



 10:34 pm on Jun 18, 2003 (gmt 0)

Yes, the repeated status causes confusion.

To stop it happening, just put the status header before the location header.


 10:38 pm on Jun 18, 2003 (gmt 0)

I've already tried it that way, still the same result.


 10:51 pm on Jun 18, 2003 (gmt 0)

I believe the Location header sets the 302 header for you. You should not try and set another header if you are doing a location command. This may be a PHP bug, as I know I have encountered it in the past.


 11:20 pm on Jun 18, 2003 (gmt 0)

The php manual says
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.

The discussion on php.net about the header function suggested setting the status code in the way I have done, but it doesn't look good.


 11:41 pm on Jun 18, 2003 (gmt 0)

Looks like a bug to me, I just never worried about it because it set a 302. You might file it under bugs.php.net


 5:52 am on Jun 19, 2003 (gmt 0)

A bit more playing and reading, and I've got it right.
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mydomain.co.nz/mydir");

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved