3

Possible Duplicate:
PHP - Referer redirect script

I am look to make script which alters browser http_referer for example

i have link

http://www.mysite.com/page.php?changeRefererTo=mysite2.com&redirectTo=www.newwebsite.com

ChangeRefererTo is holding value which will change the browser http_referer code. after changing the http_referer it will direct to $redirectTo.

is it possible with PHP?

Community
  • 1
  • 1
user1494854
  • 171
  • 1
  • 4
  • 13

2 Answers2

4

You cannot change a browser's notion of the referrer from the server. You can alter $_['http_referer'] in PHP but that only affects what PHP sees, not what the browser sees. If you were able to modify a browser's referrer, it would be a security problem since sites could force a browser to use any referrer they wanted.

However, your PHP script can fetch a page using any referrer you want, and then display the result to the user. See PHP - Referer redirect script for a worked example of this.

Community
  • 1
  • 1
nneonneo
  • 171,345
  • 36
  • 312
  • 383
1

You can't.

The referer is set by the browser(i.e. Client side). PHP runs on the server side and cannot change the client side information.

The other option would've been to change it via javascript, but browsers will not allow you to change it. If you absolutely must hit www.newwebsite.com with a referer from mysite2.com you could use cURL or similar libraries which allow you to set your own HTTP headers. This is assuming that you do not have control over mysite2.com. If you do have control over it, then you can redirect to mysite2.com from mysite.com and then redirect to www.newwebsite.com from mysite2.com.

Community
  • 1
  • 1
Anirudh
  • 388
  • 3
  • 9