Forum Moderators: phranque

Message Too Old, No Replies

double 301 responses?

         

jake66

4:37 am on Apr 26, 2006 (gmt 0)

10+ Year Member



in my /images/index.php file, i have the following code:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com");
exit();
?>

and while testing my response codes at wannabrowser.com i receive these headers:

HTTP/1.1 301 Moved Permanently
Date: Wed, 26 Apr 2006 04:36:02 GMT
Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.1 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a
Location: http://www.example.com/images/
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 301 Moved Permanently
Date: Wed, 26 Apr 2006 04:36:02 GMT
Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.1 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a
X-Powered-By: PHP/4.4.1
Location: http://www.example.com
Transfer-Encoding: chunked
Content-Type: text/html

HTTP/1.1 200 OK
Date: Wed, 26 Apr 2006 04:36:02 GMT
Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.1 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7a
X-Powered-By: PHP/4.4.1
Set-Cookie: cookieid; path=/; domain=www.example.com
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html

is this normal?

[edited by: jdMorgan at 1:27 pm (utc) on April 26, 2006]
[edit reason] Example.com [/edit]

jdMorgan

1:26 pm on Apr 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Apparently, the problem is that you're not checking the URL before you redirect it. You need to decide --and specify-- the conditions under which the script should generate a redirect, based on the requested URL.

That's the best I can offer, since you didn't state what you are trying to accomplish with this redirect.

Jim

jake66

10:09 pm on Apr 26, 2006 (gmt 0)

10+ Year Member



what i'm trying to achieve is that anyone that tries to access my images folder ( / images ) directly, is immediately redirected to my main page

jdMorgan

11:04 pm on Apr 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first redirect in the WB report is to www.example.com/images, so that is not the one inplemented in your script.

Did you perhaps requested the non-www domain when requesting the /images/ index file? If so, and if you have a non-www-to-www-domain redirect, then that would explian the two stacked redirects; The first to canoniclize the domain, and the second to redirect from /images/ to /.

Jim