Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change $_['http_referer'] in php? [duplicate]

Tags:

php

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?

like image 793
user1494854 Avatar asked Jan 30 '26 15:01

user1494854


2 Answers

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.

like image 190
nneonneo Avatar answered Feb 01 '26 04:02

nneonneo


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.

like image 22
Anirudh Avatar answered Feb 01 '26 04:02

Anirudh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!