In Progress

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.

Skills: PHP, Software Architecture

See more: return path, php software download, php create function, curl software, qs, php debug, tracking php code, php homepage, curl code, retrieve url, php random download url, curl debug, url mask, mask redirect, url mask redirect, php curl via, curl php debug, php url amp, sort contents, php cache, include php html, php file amend, php url rewriting, rewriting php, url amp php

About the Employer:
( 7 reviews ) Merseyside, United Kingdom

Project ID: #1156534

Awarded to:

hadi2f

Hi, please check your private messages for some details. Thanks

£20 GBP in 1 day
(9 Reviews)
3.3

7 freelancers are bidding on average £80 for this job

toinnisfree

quick pro help. ftp and escrow required.

£100 GBP in 1 day
(608 Reviews)
8.1
SigmaVisual

We can help in your project, please check PMB and our ratings/reviews to get idea of our experience.

£100 GBP in 1 day
(249 Reviews)
7.9
buraqtech

Check your PMB for details!!!

£103 GBP in 1 day
(88 Reviews)
7.9
brycep

Hi,Let's get it done.Thanks,Bryce

£90 GBP in 2 days
(202 Reviews)
7.8
jqMike

Would be glad to settle down your problem. Please contact me.

£100 GBP in 1 day
(64 Reviews)
7.1
Sotirov

Hello, please check PMB, Regards.

£50 GBP in 0 days
(74 Reviews)
6.9
websoft2009

Hello, I have ten experience in web development. I would like to work for you. Don't hesitate to contact me. I can start programming now.

£100 GBP in 1 day
(18 Reviews)
4.7