Just curious if it is possible to add HTTP REFERRER using PHP's header() function. Appreciate your response...
$_SERVER['HTTP_REFERER'], empty if not set MAKE SURE YOU SANITIZE IT, IT CAN BE ANYTHING, NOT JUST A URL
No not trying to find the referrer for my site.. I want to include a fake referrer from my site to a third party site. For instance if I redirect a visitor to third party site.. They shouldnt recognize my site has "http_referrer".. they should see whatever url I assign from my site. Is this possible?
Based on RFC 2616, the syntax is: header("Referer: http://google.com"); header("Location: http://yahoo.com.php"); PHP: However, this never seems to work for me. I always use fsockopen or curl instead when I need to fake the headers.
As krsix already said, referrer header is sent by the browser. You can only fake it if you try to make a HTTP request. And the short answer is no, you can't make a client's browser send fake headers like that.
If you are using PHP, you can spoof the referer with cURL: $ch = curl_init("http://google.com"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Referer: http://digitalpoint.com')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); PHP: Checkout the cURL manual at php.net for more info on cURL, it's very useful
Thanks for replying.. However cURL will not work for me as I dont intend to serve the content of third party website into my site. I just wanted my visitors to be redirected... After googling I found a double meta refresh would help to achieve my intention...