php教程|php手册
PHP,过滤,外部,链接,图片,添加,rel,amp,quo
php教程-php手册
简单分销源码下载,内网开发vscode插件,ubuntu下samba,tomcat最新什么版本,想学爬虫,php输出div,鄂州短视频seo优化,网站注册拖动图片,帝国cms如何制作模板lzw
原来站内很多文章都是摘录的外部文章,文章里很多链接要么是时间久了失效了,要么就是一些测试的网址,如:http://localhost/ 之类的,链接多了的话,就形成站内很多死链接,这对SEO优化是很不利的。那么就需要对站点内的内容进行过滤,将不是内部链接的链接
java编程思想4 源码,ubuntu安装界面翻译,可饲养的爬虫,php xdiff,渝北SEOlzw
神庙逃亡源码,ubuntu怎么解决乱码,tomcat如何不重启,docker视频爬虫,北京php商城平台分析,武汉seo_选标兵seolzw
原来站内很多文章都是摘录的外部文章,文章里很多链接要么是时间久了失效了,要么就是一些测试的网址,如:http://localhost/ 之类的,链接多了的话,就形成站内很多死链接,这对SEO优化是很不利的。那么就需要对站点内的内容进行过滤,将不是内部链接的链接加上 rel=”nofollow”属性。
网上找到了wordpress的过滤外部链接的函数,将其改一下即可使用
//外部链接增加nofllow $content 内容 $domain 当前网站域名
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;
}
调用的时候很好调用,如下是调用演示
$a[‘content’] = content_nofollow($a[‘content’],$domain); //将文章内容里的链接增加nofllow属性
注意!过滤的域名需要是不带“/”的,如
这样才可以很好的过滤。
增加对站点内容外部链接的过滤