Find Jobs
Hire Freelancers

Rewriting URLs with PHP

£20-250 GBP

Completed
Posted over 12 years ago

£20-250 GBP

Paid on delivery
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 [login to view URL] 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 = '[login to view URL]'.$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="[login to view URL]', 'href="'.$domain.$path, $content); print $content; } I then create a [login to view URL] file containing the following: $domain = "http://".$_SERVER["HTTP_HOST"]; $qs = explode('[login to view URL]', $_SERVER['REQUEST_URI']); $url = '[login to view URL]'.$qs[1]; header('HTTP/1.1 301 Moved Permanently'); header("Location: ".$url); And amend [login to view URL] to include: Disallow: /PATH_HERE/[login to view URL] 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.
Project ID: 1156534

About the project

7 proposals
Remote project
Active 13 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hi, please check your private messages for some details. Thanks
£20 GBP in 1 day
5.0 (9 reviews)
3.3
3.3
7 freelancers are bidding on average £80 GBP for this job
User Avatar
quick pro help. ftp and escrow required.
£100 GBP in 1 day
4.9 (608 reviews)
8.1
8.1
User Avatar
We can help in your project, please check PMB and our ratings/reviews to get idea of our experience.
£100 GBP in 1 day
4.8 (249 reviews)
7.9
7.9
User Avatar
Check your PMB for details!!!
£103 GBP in 1 day
4.8 (88 reviews)
7.9
7.9
User Avatar
Would be glad to settle down your problem. Please contact me.
£100 GBP in 1 day
4.9 (64 reviews)
7.1
7.1
User Avatar
Hello, please check PMB, Regards.
£50 GBP in 0 day
5.0 (74 reviews)
6.9
6.9
User Avatar
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
5.0 (18 reviews)
4.7
4.7

About the client

Flag of UNITED KINGDOM
Merseyside, United Kingdom
5.0
7
Payment method verified
Member since Aug 7, 2011

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.