Devam Ediyor

515839 Rewriting URLs with PHP

Hi,

I have a site which lists products via 3rd party affiliate links. The links are displayed on my site via PHP, I wish to mask the url so it appears to be on my domain, instructions have been provided and implemented but for some reason, the links only work one time then rather than redirecting to the 3rd party site, they redirect to my homepage, as if some sort of Curl or PHP or server caching is taking place.

Here's the documentation:

/*

Retrieve HTML for [url removed, login to view] product unit.

Note: 'fopen wrappers' must be enabled. Requires PHP 4.3.0. or above.

*/

/*

Code by Bob DeVeaux for ECU

This re-writes the ECU link to the same domain as the code

*/

// function for downloading file

function curl_get_file_contents($URL)

{

$c = curl_init();

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_URL, $URL);

curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 5000);

curl_setopt($c, CURLOPT_TIMEOUT, 10000);

$contents = curl_exec($c);

curl_close($c);

if ($contents)

{

return $contents;

}

else

{

return false;

}

}

$ecu_mid = 839; // your member id

$ecu_uid = 20212; // your unit id

$ecu_tracking = ''; // optional tracking id

$ecu_keywords = ''; // optional keywords for random product unit

$ecu_debug_mode = 'no'; // debug mode (yes or no)

$domain = "http://".$_SERVER["HTTP_HOST"];

$path = '/blog';

$ecu_url =

'[url removed, login to view]'.$ecu_mid

.'&ecu_uid='.$ecu_uid.'&ecu_tracking='.urlencode($ecu_tracking).

'&ecu_keywords='.urlencode($ecu_keywords).'&debug='.$ecu_debug_mode;

// cURL download file.

if($content = curl_get_file_contents($ecu_url))

{

$content = str_replace('href="[url removed, login to view]',

'href="'.$domain.$path, $content);

print $content;

}

I then create a [url removed, login to view] file containing the following:

$domain = "http://".$_SERVER["HTTP_HOST"];

$qs = explode('[url removed, login to view]', $_SERVER['REQUEST_URI']);

$url = '[url removed, login to view]'.$qs[1];

header('HTTP/1.1 301 Moved Permanently');

header("Location: ".$url);

And amend [url removed, login to view] to include:

Disallow: /PATH_HERE/[url removed, login to view]

Like I say, it appears to work, and does so on first clicks, but from then on, it doesn't work due to cache or something?!

Thanks,

Peter.

Beceriler: Her şey Kabul, Blog

Daha fazlasını görün: bob deveaux php, return path, url rewriting, QS, php debug, php curl http code, tracking php code, php http redirect, retrieve url, php random download url, curl debug, url mask, mask redirect, url mask redirect, php curl via, curl php debug, blog product link, sort contents, php cache, php file amend, php url rewriting, rewriting php, member function php, php sort url, moved url

İşveren Hakkında:
( 7 değerlendirme ) Merseyside, United Kingdom

Proje NO: #2261771