Welcome to WebmasterWorld Guest from 107.22.83.0

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Correct status

Am I causing confusion

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

Full Member

10+ Year Member

joined:Mar 18, 2002
posts:309
votes: 0


My script reads

<?php
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/5.0.2.2510 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 June 18, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 9, 2003
posts:28
votes: 0


Yes, the repeated status causes confusion.

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

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

Full Member

10+ Year Member

joined:Mar 18, 2002
posts:309
votes: 0


I've already tried it that way, still the same result.
10:51 pm on June 18, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 6, 2002
posts:1092
votes: 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 June 18, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Mar 18, 2002
posts:309
votes: 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 June 18, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 6, 2002
posts:1092
votes: 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 June 19, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Mar 18, 2002
posts:309
votes: 0


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