Forum Moderators: phranque

Message Too Old, No Replies

redirecting while keeping referrer info

         

minky

9:51 pm on May 26, 2008 (gmt 0)

10+ Year Member



Hi Guys,

I currently have my site running a toplist script with all traffic coming into "IN.PHP" as per normal.

Now i want to a different traffic script, My question is how can i redirect all the traffic coming into
"IN.PHP" to the new main page "INDEX.PHP" and keeping all the referer info so the new traffic script can track referers.

Im trying to do it through htaccess at the moment but my knowledge is lmited to say the least,
Ive tried this in a htaccess file:

Redirect 301 /in.php [mydomain.com...]

Which does redirect the surfer to the index.php page but all the referer info is lost and my new
trade script just picks up the referer as "http://www.mydomain.com/index.php" which is obviously no use.

Any one any ideas?

Thanks in advance guys.

jdMorgan

11:21 pm on May 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use mod_rewrite [httpd.apache.org] instead of mod_alias, and do an internal rewrite of the URL to the /index.php filepath, not an external redirect.

Jim

minky

2:50 pm on May 27, 2008 (gmt 0)

10+ Year Member



Hey Jd, thanks for the reply....
Could you explain a bit more for me?

g1smd

3:12 pm on May 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You'll need a RewriteCond as before.

This will connect the requested URL with the new internal filepath.

As it is a rewrite it will NOT have an [R] or [R=301] parameter on the end.

There's several thousand prior example code snippets here in the forum, and notes in several tutorials to get you started.

Receptional Andy

3:19 pm on May 27, 2008 (gmt 0)



As far as I'm aware, a 301 will pass the referrer info in most (all?) modern browsers, so I don't think the redirect is the issue here.

minky

3:38 pm on May 27, 2008 (gmt 0)

10+ Year Member



Hey Guys,

Thanks, ive come up with this:

<?php
{
header("Location: {$GLOBALS['FORWARD_URL']}");
exit;
}
?>

As an alternative ive replaced the contents of the old toplist in.php with the code above, So every time a server comes in through the old in.php linking method it does redirect to the index.php page i wanted it to and it keeps the referer info as i wanted.

However i have no idea how it works...

Will this method cause me any known problems does anyone know?

Thanks again guys.