homepage Welcome to WebmasterWorld Guest from 54.211.73.232
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Refferrer URL Not Getting Passed in PHP Re-direction
Please help
bigdealioo

5+ Year Member



 
Msg#: 3064348 posted 1:51 pm on Aug 29, 2006 (gmt 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!

 

barns101

5+ Year Member



 
Msg#: 3064348 posted 2:36 pm on Aug 29, 2006 (gmt 0)

Using header('Location: http://www.example.com'), C will see A as the referrer.

bigdealioo

5+ Year Member



 
Msg#: 3064348 posted 10:09 pm on Aug 29, 2006 (gmt 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.

dimeric

5+ Year Member



 
Msg#: 3064348 posted 11:53 pm on Aug 29, 2006 (gmt 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?

bigdealioo

5+ Year Member



 
Msg#: 3064348 posted 12:02 am on Aug 30, 2006 (gmt 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).

barns101

5+ Year Member



 
Msg#: 3064348 posted 12:30 am on Aug 30, 2006 (gmt 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');

bigdealioo

5+ Year Member



 
Msg#: 3064348 posted 1:30 am on Aug 30, 2006 (gmt 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.

barns101

5+ Year Member



 
Msg#: 3064348 posted 1:36 am on Aug 30, 2006 (gmt 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]

dimeric

5+ Year Member



 
Msg#: 3064348 posted 1:37 am on Aug 30, 2006 (gmt 0)

try this for something quite generic:

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

bigdealioo

5+ Year Member



 
Msg#: 3064348 posted 1:09 pm on Aug 30, 2006 (gmt 0)

dimeric, that code gives me an error

barns101

5+ Year Member



 
Msg#: 3064348 posted 3:25 pm on Aug 30, 2006 (gmt 0)

I believe that it should read

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

dimeric

5+ Year Member



 
Msg#: 3064348 posted 11:25 pm on Aug 30, 2006 (gmt 0)

woops sorry my code is wrong its a ] not a ) at the end

Filipe

10+ Year Member



 
Msg#: 3064348 posted 2:59 am on Aug 31, 2006 (gmt 0)

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

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

and it'll be transparent!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved