YD8877
YD8877

Reputation: 10790

How to spoof site referrer?

I have 2 pages :

1.php and 2.php

When the user arrives on 2.php, i want to show on 2.php that the user is arriving from google.com and NOT from 1.php

I tried spoofing the header of 2.php using

<?php
header();
?>

when i do a javascript document.write(document.referrer); it shows me 1.php

Any help is appreciated.

Upvotes: 1

Views: 2898

Answers (4)

Esben Eickhardt
Esben Eickhardt

Reputation: 3852

You can just use cURL:

curl --referer http://fakereferrer.com http://targetwebsite.com

Upvotes: 0

David
David

Reputation: 11

You can use PHP CURL to call the page and fake a referring URL, user agent, and other variables.

Upvotes: 1

PleaseStand
PleaseStand

Reputation: 32082

Are you trying to test a referrer check? The easiest way to do it — no browser plug-in required — is to use a javascript: URL:

javascript:location="http://your.web.server/2.php"

Open http://www.google.com/ and paste that into the address bar. It will open 2.php, with the referrer being http://www.google.com/. The only problem I am aware of is that this does not work on Internet Explorer 6.

Upvotes: 3

Matthew
Matthew

Reputation: 48284

The http referrer is a request header. The server (PHP) can only set response headers.

Thus the only way to spoof a referrer is for the client to do it, usually via some sort of browser plugin.

Upvotes: 4

Related Questions