WordPress网站添加外链go跳转效果

admin wordpress评论262

电脑端效果

WordPress网站添加外链go跳转效果

手机端效果

WordPress网站添加外链go跳转效果文章源自小虫博客-https://www.xczi.cn/wordpress/401.html

新建一个go.php文件,放置到网站的根目录下,在go.php里面输入:文章源自小虫博客-https://www.xczi.cn/wordpress/401.html

此处为隐藏的内容
注册登录后,方可查看隐藏内容

找到模板的functions.php文件添加:文章源自小虫博客-https://www.xczi.cn/wordpress/401.html

//评论者链接添加go跳转
function add_redirect_comment_link($text = ''){
    $text=str_replace('href="', 'href="'.get_option('home').'/go.php/?url=', $text);
    return $text;
}
add_filter('get_comment_author_link', 'add_redirect_comment_link', 5);
add_filter('comment_text', 'add_redirect_comment_link', 99);

//文章内外链添加go跳转
function the_content_nofollow($content){
    preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/',$content,$matches);
    if($matches){
        foreach($matches[2] as $val){
            if(strpos($val,'://')!==false && strpos($val,home_url())===false && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val)){
                $content=str_replace("href=\"$val\"", "href=\"".home_url()."/go.php/?url=$val\" ",$content);
            }
        }
    }
 return $content;
}
add_filter('the_content','the_content_nofollow',999);

以上代码增加了跳转美化效果,代码中已经用 base64 将源链接加密,并且加上了 nofollow,但恐怕蜘蛛还是能爬行,在 Robot 禁止所有蜘蛛爬行 /go?url 目录!文章源自小虫博客-https://www.xczi.cn/wordpress/401.html

Disallow: /go/  
Disallow: /go?url

 文章源自小虫博客-https://www.xczi.cn/wordpress/401.html 文章源自小虫博客-https://www.xczi.cn/wordpress/401.html

admin


  • ·版权声明·



    1、本站文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系客服进行删除处理。
    2、本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
    3、如有侵权请邮件admin@xczi.cn与我们联系处理。敬请谅解!


  • 转载请务必保留本文链接:WordPress网站添加外链go跳转效果-https://www.xczi.cn/wordpress/401.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: