If you use Wordpress, there are some plugins adding nofollow to certain, external domains. If no wordpress, try something like this script:
function add_nofollow( $content ) {
$my_xurl = "*.openstreetmap.fr";
$my_purl = "*.tile.openstreetmap.fr";
preg_match_all( '~<a.*>~isU', $content, $uri_match );
for ( $i = 0; $i <= sizeof( $uri_match[0] ); $i ++ ) {
if ( isset( $uri_match[0][ $i ] ) && ! preg_match( '~nofollow~is', $uri_match[0][ $i ] )
&& ( preg_match( '~' . preg_quote( $my_xurl ) . '~', $uri_match[0][ $i ] ))
&& ( preg_match( '~' . preg_quote( $my_purl ) . '~', $uri_match[0][ $i ] ))
) {
$uri_change = trim( $uri_match[0][ $i ], ">" );
$uri_change .= ' rel="nofollow">';
$content = str_replace( $uri_match[0][ $i ], $uri_change, $content );
}
}
return $content;
}
add_filter( 'the_content', 'add_nofollow' );