fris
By: a guest | Mar 22nd, 2010 | Syntax:
PHP | Size: 0.24 KB | Hits: 81 | Expires: Never
// add nofollow to all external links
function change_links($text) {
$host = str_replace('.','\.',getenv("HTTP_HOST"));
return preg_replace('/href=["|\']?(http:\/\/(?!'.$host.')([^"\']*))["|\']?/ui','href="$1" rel="nofollow"',$text);
}