need 301 redirect help

Status
Not open for further replies.

DewChugr

Photoshop God
Jun 26, 2006
1,977
66
0
48.655139,-119.644032
I have one site on Apache that is being moved to a new domain on an IIS server. Yeah, I know, but it's not my choice.

I want to be able to pull the referrer in php so that I can display a message to users that got redirected from the old site to the new site.

I have this htaccess rule that redirects as expected.
RewriteRule (.*) http://www.newsite.org/$1 [R=301,L]

But when I try to pull the referrer on the new site I get nothing.

Does the referring url get passed with a 301? Is there something I need to fo to make this work?
 


I think I might not have explained it well. I have the redirect on the unix box and I when the user is redirected to the windoze box I want to know that they came from the old domain instead of google or wherever.

Thanks
 
I think I might not have explained it well. I have the redirect on the unix box and I when the user is redirected to the windoze box I want to know that they came from the old domain instead of google or wherever.

Thanks

You might actually have to pass the referrer thru to the destination.
If both boxes are yours, you can probably set a cookie that they've passed thru from the other box. Otherwise I don't think that one server is going to be able to see the referrer prior to being redirected from the first server.
 
The referrer of the original request should be passed in a 301. But I don't think it's the actual referer header you want. In other words somebody clicks on a link that points to oldsite.org. The page that link was on will be passed to the newsite.org as the referer. But if they just type in oldsite.org and it redirects then there's no referrer.

Sounds like you need to differentiate the redirected requests from the not-redirected ones, so you could pass the redirecting site's hostname in the querystring ..

RewriteRule (.*) http://www.newsite.org/$1?%{QUERY_STRING}&from=%{HTTP_HOST} [R=301,L]
 
Sounds like you need to differentiate the redirected requests from the not-redirected ones, so you could pass the redirecting site's hostname in the querystring ..

RewriteRule (.*) http://www.newsite.org/$1?%{QUERY_STRING}&from=%{HTTP_HOST} [R=301,L]

Sounds like that might do exactly what I need. Thanks a lot!
 
Status
Not open for further replies.