CURL Redirect while blocking the referrer

  • benwade9721
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

Hi everyone,

I am trying to link to another website while blocking my site as the referrer, I don't want my site to come up in their logs, I am using the following code:

Code: [ Select ]
<?
$referer = "http://www.other-referrer.net/";
$url = "http://www.target-site.org";

$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close($ch);
?>
  1. <?
  2. $referer = "http://www.other-referrer.net/";
  3. $url = "http://www.target-site.org";
  4. $ch = curl_init();
  5. curl_setopt($ch, CURLOPT_REFERER, $referer);
  6. curl_setopt($ch, CURLOPT_URL, $url);
  7. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  8. curl_exec($ch);
  9. curl_close($ch);
  10. ?>


The code grabs the content of the target site, but the url in the address bar stays on my website, I want it to redirect/go to the website while blocking my referrer id.

Am I on the right track?

Cheers,

Ben
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

I don't know since I never used CURL, but I know that you can do the following.
Code: [ Select ]
<?
$referer = "http://www.other-referrer.net/";
$url = "http://www.target-site.org";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close($ch);
?>
  1. <?
  2. $referer = "http://www.other-referrer.net/";
  3. $url = "http://www.target-site.org";
  4. $ch = curl_init($url);
  5. curl_setopt($ch, CURLOPT_REFERER, $referer);
  6. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  7. curl_exec($ch);
  8. curl_close($ch);
  9. ?>

But if you like, you can test it can't you? both of those URLs (The referer and the url) would be your pages, and the URL (The place where you are redirecting) would echo $_SERVER['referrer'] and if it says as a lie than it works... if it's not lieing than it doesn't work.

But that doesn't work for my test... but I don't know if I did it correctly though.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

This is what happens during a redirect.

1) Your server gets the request from the visitors browser.

2) Your server returns a new URL to the browser and says "Go here instead".

2b) It is out of your control now, there is nothing more you can do.

3) The browser gathers details about where it was just at, which happens to be your server, and includes that information when making the request to the server your server told it to go to.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 123 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.