Spacer
Spacer

NGCODERS.COM

[ NEXT GENERATION CODERS ]

Spacer


I have some sites which have been running for a long while, and due to not having time on my part to upgrade them they still run pretty old scripts with custom coding ( If it aint broke dont fix it :) ). Some time back i realized the rel=”nofollow” thing and how people posting links on those sites got Backlinks for free. After doing a little backlink checking i found that my sites were linking to competitor sites , which is totaly unacceptable.Also with so maybe free backlinks going out PR can be affected ( am not shore about that though ). So with a few lines of PHP you can kill all free back links people have been getting through ur side.

So if you are stuck with the same situation here is a little help , Assuming your site is running in php. What we do is buffer all the content and find all non site links and replace them with a additional nofollow tag.

ob_start();

// Your sites code goes here

$content = ob_get_contents();
@ob_end_clean();

preg_match_all(’!href[\s]*=[\s]*["\']{1}([\w]+?://[\w#$%&~/.\-;:=,?@\[\]+]*)["\']{1}!’,$content,$matches);

// Replace all outbound links with nofollow

$replaced = array();

for($i=0;$i<count($matches[0]);$i++)
{
if(strstr($matches[1][$i],’http://www.sitename.com’)) continue;
if(strstr($matches[1][$i],’http://sitename.com’)) continue;

if(in_array($matches[0][$i],$replaced))continue;

$content = str_replace($matches[0][$i],$matches[0][$i].’ rel=”nofollow”‘,$content);

$replaced[] = $matches[0][$i];
}

echo $content;

Now i hope this code increases the PR for the sites , they are PR 5 for now … will post results if i see any changes in the site stats.


No Responses to “Adding nofollow to all outbound links to increase pagerank”  

  1. No Comments

Leave a Reply



About

You are currently browsing the NGCoders - Next Generation Coders weblog archives.

Categories

Subscribe