Page 1 of 1

how to send referer while redirecting with header()?

Posted: Thu Nov 04, 2004 5:06 pm
by xnex
does anyone know how to send referer while redirecting with header()?

for example I have 2 pages,
redir.php has

Code: Select all

header("Location: http://blah.com/receive.php");
and receive.php has

Code: Select all

echo $HTTP_SERVER_VARSї'HTTP_REFERER'];
receive.php doesn't show anything for the referer, but I want it to have redir.php as the referer

I've tried putting this infront of the header() but it doesn't do anything
header("Referer: http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html");

thanks for any help 8)

Weirdan | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Thu Nov 04, 2004 5:32 pm
by Weirdan
HTTP_REFERER is supposed to be tracked by user's browser, if it does not return the referer to your site you can't do anything about it. But you may pass the values from 'redir' to 'receive' via GET variables like this:

Code: Select all

header('Location: http://example.com/receive.php?referred_by=' . urlecode($_SERVERї'SCRIPT_URI']));

Code: Select all

echo isset($_GETї'referred_by']) ? $_GETї'referred_by'] : 'random hit';

Posted: Thu Nov 04, 2004 6:01 pm
by xnex
I was just using receive.php to test it, I would really be redirecting to sites other than mine.

is there no way to make sure it send a http referer, even a fake one?

thanks for the reply

Posted: Thu Nov 04, 2004 6:51 pm
by rehfeld
xnex wrote:I was just using receive.php to test it, I would really be redirecting to sites other than mine.

is there no way to make sure it send a http referer, even a fake one?

thanks for the reply
nope