php专区

 首页 > php专区 > PHP应用 > CMS建站 > Discuz帖子内容中的外部链接加上rel=nofollow - Disc

Discuz帖子内容中的外部链接加上rel=nofollow - Disc

分享到:
【字体:
导读:
          帖子中可能会有很多用户加上外部链接,可以加上nofollow来降低导出权重,只保留本站域名的链接,即链接中本站域名出现在最开始的位置,认定为合法的内部链接 修改文件:source function func...

Discuz帖子内容中的外部链接加上rel=nofollow

帖子中可能会有很多用户加上外部链接,可以加上nofollow来降低导出权重,只保留本站域名的链接,即链接中本站域名出现在最开始的位置,认定为合法的内部链接.

修改文件:source/function/function_discuzcode.php

  1. function p arseurl($url$text$scheme) { 
  2.         glob al $_G
  3.         if(!$url && preg_m atch("/((https?|ftp|gopher|news|telnet|rtsp|mms|c allto|bctp|thunder|qqdl|syn ac ast){1}://|www.)[^["']+/i", trim($text), $m atches)) { 
  4.                 $url = $m atches[0]; 
  5.                 $length = 65; 
  6.                 if(strlen($url) > $length) { 
  7.                         $text = substr($url, 0, intv al($length * 0.5)).' ... '.substr($url, - intv al($length * 0.3)); 
  8.                 } 
  9.                 $nofllow = strpos($url$_G['siteurl']) !== 0 ? '" rel="nofollow' : ''
  10.                 return '< a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url) . $nofllow .'" t arget="_bl ank">'.$text.''
  11.         } else { 
  12.                 $url = substr($url, 1); 
  13.                 if(substr(strtolower($url), 0, 4) == 'www.') { 
  14.                         $url = 'http://'.$url
  15.                 } 
  16.                 $url = !$scheme ? $_G['siteurl'].$url : $url
  17.                 $nofllow = strpos($url$_G['siteurl']) !== 0 ? '" rel="nofollow' : ''
  18.                 return '< a href="'.$url . $nofllow .'" t arget="_bl ank">'.$text.''
  19.         } 
分享到:
Discuz X3.1使用心得——上传头像错误 - ...
Discuz X3.1使用心得——上传头像错误 1、上传头像出现提示data/tmp写入错误. 解决办法:增加uc_server/data/tmp的写入权限. 命令:chmod ugo+rwx tmp 2、保存照片是提示网络错误 解决办法:增加uc_server/data/avatar的写入权限 命令:chmode ugo+rwx avatar
DISCUZ X3实现LINUX 虚拟主机环境下的301...
DISCUZ X3实现LINUX 虚拟主机环境下的301+伪静态教程 只适用于DISCUZ X系列,首先登录后台,然后进全局,SEO里设置,记住,设置好伪静态后,记得更新缓存,再去全局里 查看当前的伪静态规则并复制,还有,新手的一个失败原因就是 RewriteBase / 这里. 比如你的DZ在空间的路径是这样的:/domains/www.ab...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……