/** * 外键处理 */ //外部链接增加nofllow $content 内容 $domain 当前网站域名 function content_nofollow($content,$domain){ preg_match_all('/href="(.*?)"/',$content,$matches); show($matches); if($matches){ foreach($matches[1] as $val){ if( strpos($val,$domain)===false ) $content=str_replace('href="'.$val.'"', 'href="'.$val.'" rel="external nofollow" ',$content); } } preg_match_all('/src="(.*?)"/',$content,$matches); if($matches){ foreach($matches[1] as $val){ if( strpos($val,$domain)===false ) $content=str_replace('src="'.$val.'"', 'src="'.$val.'" rel="external nofollow" ',$content); } } return $content; }