人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

業(yè)界新聞動(dòng)態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁(yè)      樂(lè)道系統(tǒng)FAQ      增加對(duì)站點(diǎn)內(nèi)容外部鏈接的過(guò)濾

增加對(duì)站點(diǎn)內(nèi)容外部鏈接的過(guò)濾

標(biāo)簽: 發(fā)布日期:2014-05-03 19:28:00 1443

原來(lái)站內(nèi)很多文章都是摘錄的外部文章,文章里很多鏈接要么是時(shí)間久了失效了,要么就是一些測(cè)試的網(wǎng)址,如:http://localhost/ 之類(lèi)的,鏈接多了的話,就形成站內(nèi)很多死鏈接,這對(duì)SEO優(yōu)化是很不利的。那么就需要對(duì)站點(diǎn)內(nèi)的內(nèi)容進(jìn)行過(guò)濾,將不是內(nèi)部鏈接的鏈接加上 rel="nofollow"屬性。

網(wǎng)上找到了wordpress的過(guò)濾外部鏈接的函數(shù),將其改一下即可使用

//外部鏈接增加nofllow $content 內(nèi)容 $domain 當(dāng)前網(wǎng)站域名
function content_nofollow($content,$domain){
 preg_match_all('/href="(.*?)"/',$content,$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;
}
 
調(diào)用的時(shí)候很好調(diào)用,如下是調(diào)用演示
 
$a['content'] = content_nofollow($a['content'],$domain);    //將文章內(nèi)容里的鏈接增加nofllow屬性
 
注意!過(guò)濾的域名需要是不帶“/”的,如http://www.bbcq1.cn
 
這樣才可以很好的過(guò)濾。