deki
deki

Reputation: 31

Curl Referer and Redirect

I want to fake referrer with curl and current code is working fine:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.target-url.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.facebook.com/');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
$html = curl_exec($ch);
curl_close ( $ch );
echo $html;

Problem that I want to solve is that when I run code URL in browser stay the same (in top of browser where you enter URL). So URL of page where is code stay on top. But I would like to have real redirect like with header( 'Location: ') command.

Can you help with this ?

Upvotes: 1

Views: 8741

Answers (1)

evan
evan

Reputation: 12553

If you would like a real redirect, then just use the header('Location: ' . $url) command after you've done whatever you want to do.

You cannot put another url into the address bar for security reasons.

If you could, hackers would spam you with emails as they do now with fake emails that look real. Then if you followed their links it would look like you were on the real site (such as a bank) and they would steal your username and password when you entered them. They already do this for people that are unaware, but it would make the problem even worse if you could do what you requested.

Upvotes: 0

Related Questions