Welcome to WebmasterWorld Guest from 54.163.52.98

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Correct status

Am I causing confusion

     

olwen

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

10+ Year Member



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.

mischief

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

10+ Year Member



Yes, the repeated status causes confusion.

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

olwen

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

10+ Year Member



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

Lisa

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

WebmasterWorld Senior Member 10+ Year Member



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.

olwen

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

10+ Year Member



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.

Lisa

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

WebmasterWorld Senior Member 10+ Year Member



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

olwen

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

10+ Year Member



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");
?>
 

Featured Threads

Hot Threads This Week

Hot Threads This Month