This has been taken from the blog over at Insight-UK, where the affiliate manager Bob came up with the method for you to rewrite your URLs, here it is straight from the post:
There are currently 2 methods to embed the Content Units into your website. JavaScript, or PHP. The JavaScript method is the easiest but is not the best as Search Engines cannot index JavaScript. If you have the technical skills, you can drop the PHP code that ECU supply directly into your website. This allows search engines to know what products you are offering. However, there is still the downside that for every product you promote you have an external link to easycontentunits.com. This is generally bad SEO practice as every external link is a drop in page rank. Thankfully, ECU provide the ‘rel=”nofollow”‘ code in the anchor tags, so you shouldn’t be penalised too much, if at all. In addition, most PHP servers have a security setting which prevent this code from running.
There is the fact that some folks just prefer to see that the links are on their own website, rather than an external website. For this reason, I’ve come up with a different bit of PHP code. If you use the PHP code supplied by ECU; then I’d highly recommend you implement this code. For an example of both php methods go here:
http://iq.insight.com/blog/ecu.php
The code is as follows and goes wherever you want the content unit.
/*
Retrieve HTML for Easycontentunits.com 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 =
'http://www.easycontentunits.com/phpunit.php?ecu_mid='.$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="http://www.easycontentunits.com',
'href="'.$domain.$path, $content);
print $content;
}
You then need your own version of product.php in the location you specified for ‘$path’.
$domain = "http://".$_SERVER["HTTP_HOST"];
$qs = explode('product.php', $_SERVER['REQUEST_URI']);
$url = 'http://www.easycontentunits.com/product.php'.$qs[1];
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".$url);
The final step is to prevent search engines from spidering the redirect page by editing your robots.txt.
Disallow: /PATH_HERE/product.php
Amazon Users
If you have products from Amazon in your units, you will also need to add the following page:
amazon_product.php in the location you specified for ‘$path’.
$domain = "http://".$_SERVER["HTTP_HOST"];
$qs = explode('amazon_product.php', $_SERVER['REQUEST_URI']);
$url = 'http://www.easycontentunits.com/amazon_product.php'.$qs[1];
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".$url);
Plus the robots file will need amending to:
Disallow: /PATH_HERE/product.phpDisallow: /PATH_HERE/amazon_product.php
I’d like to thank Bob DeVeaux for coming up with this solution for us. If you would like to include any Insight products in units, or indeed use their Weekly Deals managed unit, that would help thank them for this useful code.
[...] This post was mentioned on Twitter by Keith Bond, Big Idea Media. Big Idea Media said: @carlhendy Sorry for the delay, don't always check tweets as often as tickets – I have added a post which should help http://bit.ly/bvB8VP [...]
Thanks for this, I just tried it out and it looks cool.
I noticed that amazon feeds use amazon_product.php instead of product.php will this effect things or will it still work OK?
Hi Matt
Well spotted, yes, you will need a separate php page for the amazon products, I will update the article for you above
Going to give this a go tonight! watch me make a mess of my site!
Glad you folks like it
I’m giving this a go today, fingers crossed!