Last week Richardo Dacosta asked me a very interesting question:
Your contribution prevents the spiders from reading the osCsid. Would I be able to use it to prevent spiders from seeing lets say: “ref=53&affiliate_banner_id=16” from my affiliates? if so, what do I have to do to make it work?
In my last days to my wedding, it got me thinking and finding (another) quick and dirty solution, to redirect search engines to the right URL without the affiliate references. This way links from affiliate websites add up to your original (product) page!
The solution is simple: just add the affiliate references in the $search variable. As example, we would like to catch the “ref” and “affiliate_banner_id” affiliate references.
Original:
$search = '\&osCsid.*|\?osCsid.*'; // searches for the session id in the url
Edit this line to catch your affiliate references
$search = '\&osCsid.*|\?osCsid.*'.'\&ref.*|\?ref.*'.'\&affiliate_banner_id.*|\?affiliate_banner_id.*'; // searches for the session id in the url
That’s it! Now the canonical will redirect the search engines to your original (product) page. This will prevent duplicate content and will help you get more authority on your product page which has affiliates.
If you still have problems with the trailing slash and the canonical (i.e. URL is missing the last letter of your TLD), try this:
Original:
$domain = substr((($request_type == ‘SSL’) ? HTTPS_SERVER : HTTP_SERVER), 0, -1); // gets the base URL minus the trailing slash
Remove the [, -1] from the code so it looks like this
Edit this line to have a proper trailing slash:
$domain = substr((($request_type == ‘SSL’) ? HTTPS_SERVER : HTTP_SERVER), 0); // gets the base URL minus the trailing slash
Get the original Canonical URL contribution
***** REMEMBER TO BACK UP files before making any changes ******