Welcome to WebmasterWorld Guest from 54.159.50.111

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Refferrer URL Not Getting Passed in PHP Re-direction

Please help

     
1:51 pm on Aug 29, 2006 (gmt 0)

Full Member

5+ Year Member

joined:Aug 26, 2006
posts:236
votes: 0


Surfer is coming from A to B. At B, there's a PHP redirect to C. Site B redirects to C, without giving C referrer information. Site C sees Refferrer field as blank. I'd like site C to see site B as a Refferrer. Thanks!
2:36 pm on Aug 29, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 6, 2005
posts:575
votes: 0


Using header('Location: http://www.example.com'), C will see A as the referrer.
10:09 pm on Aug 29, 2006 (gmt 0)

Full Member

5+ Year Member

joined:Aug 26, 2006
posts:236
votes: 0


<?
header('Location: [SITE-C.com');...]
?>

This is the index.php on site B which does the redirection to Site C.

As of now... NO referrer is getting passed. That is the problem.

11:53 pm on Aug 29, 2006 (gmt 0)

New User

5+ Year Member

joined:Aug 29, 2006
posts:6
votes: 0


Thats because nothing is reffering it! Changing the header is not the same as a link as all you arn't being reffered to the page you are merely changing the header (like just entering the URL into your URL bar in a browser). You could try some sort of META refresh but im not sure if thats any different.

There must be a way round it, perhaps you could pass the B URL as a GET Var?

12:02 am on Aug 30, 2006 (gmt 0)

Full Member

5+ Year Member

joined:Aug 26, 2006
posts:236
votes: 0


Well.. I have no idea how to do this but I need to pass some referrer to site C (it can be site B or site A as referrer, although I prefer B).
12:30 am on Aug 30, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 6, 2005
posts:575
votes: 0


OK this works, I have just tested it:

  • page-a.php contains an HTML text link to page-b.php
  • page-b.php simply contains the code
    header('Location: page-c.php');

  • page-c.php echos the referrer.

When clicking the link on page-a.php I am taken to page-c.php and the referrer is shown as page-a.php

If you get a blank referrer then maybe:

a) Your code for displying the referrer is incorrect
b) Your browser or security software is not supplying the referrer
c) There's some different between my server and yours so that they exhibit different behaviour

You could pass a referrer variable in the URL, as previously suggested:

header('Location: page-c.php?referrer=page-b.php');
1:30 am on Aug 30, 2006 (gmt 0)

Full Member

5+ Year Member

joined:Aug 26, 2006
posts:236
votes: 0


barns... it seems to work when all 3 files are on the same server (site). but when site B redirects to external site C, its a different story and the referral gets lost. try it.
1:36 am on Aug 30, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 6, 2005
posts:575
votes: 0


Localhost -> remote server passes the referrer for me, too.

I didn't know that the referrer would be passed until recently, when I saw it show up in an affiliate report where a header(Location: ) was used to redirect visitors.

It definitely works. Check your browser/server settings. :)

[edited by: barns101 at 1:38 am (utc) on Aug. 30, 2006]

1:37 am on Aug 30, 2006 (gmt 0)

New User

5+ Year Member

joined:Aug 29, 2006
posts:6
votes: 0


try this for something quite generic:

[codes]header("Location: page-c.php?referrer=$_SERVER['PHP_SELF"); [/codes]

1:09 pm on Aug 30, 2006 (gmt 0)

Full Member

5+ Year Member

joined:Aug 26, 2006
posts:236
votes: 0


dimeric, that code gives me an error
3:25 pm on Aug 30, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 6, 2005
posts:575
votes: 0


I believe that it should read

header("Location: page-c.php?referrer=$_SERVER[PHP_SELF]");
11:25 pm on Aug 30, 2006 (gmt 0)

New User

5+ Year Member

joined:Aug 29, 2006
posts:6
votes: 0


woops sorry my code is wrong its a ] not a ) at the end
2:59 am on Aug 31, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 25, 2002
posts:470
votes: 0


Guys, guys, you're doing it the hard way. Just pass another header:

header('Referer: '.$_SERVER['PHP_SELF']);

and it'll be transparent!