I recently wrote an article about how to create a PHP redirect manually on one of my other websites. I use this to make my affiliate links look pretty and also to let the clicker know what they are clicking on.
The problem is, this creates a link to a page on your site that is really not in existence. Therefore I do not want to let Google index or follow this link as it only leads to an affiliates website.
So this is why I like to add nofollow to a PHP redirect, or even a “no index”.
How to Add Nofollow to a PHP Redirect
Well I am great with HTML but PHP is not my finer suit. That is why I had to “Google” this problem and find the answer. I came up with two possible answers.
You cannot add NOFOLLOW to a PHP redirect!
NOFOLLOW is only associated with anchor tags <a> in HTML
If you want to stop search engines giving value to your affiliate links, then make the link a 302 links. This means its temporary.
So something like this will work :
<?php header(‘Location: http://some-affiliate-link.com’,302); ?>
Hope this helps
This answer is from Yoast.
If you want to prevent search engines from showing files you’ve generated with PHP, add the following in the header file:
header("X-Robots-Tag: noindex", true);
This would not prevent search engines from following the links on those pages, if you want to do that, do the following:
header("X-Robots-Tag: noindex, nofollow", true);
My original PHP redirect code
header( ‘Location: http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=Mitzpantic-‘ ) ;
Now using solution 1
header( ‘Location: http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=Mitzpantic-‘,302) ;
Personally I tried the first solution and thought it was very easy.
Video – How to Cloak Affiliate Links Manually
Here is the video showing how to redirect the links in the first place.
Also see more info here: how to create a PHP redirect manually