A-A+
	wordpress博客评论添加goto跳转的形式
现在的博客cms基本上都是支持评论的,如果不能够支持评论功能,也就算不上是博客程序了,在博客之间互访时,博客主都会留下自己的网址,以便于能够获得相应的流量ip互访,而在默认的wordpress博客评论中,点击留言者的网址是直接跳转的,在这种情况下,如果留言越来越多的话,会严重影响自己站点的权重,所以国内的博客主题在评论的地方都是经过加工的。
看到不少的博客都是使用的goto跳转的形式来避免传递权重的,效果就类似于 http://www.xiariboke.net/goto.php?url=网站链接,这样的话,就相当于由外链转内链了,对于汇集自己站点的权重是很有好处的,实现这样的功能也是相当的简单,首先goto.php是一个真实的php文件所存在的,首先建立这个文件,代码如下:
- <!doctype html>
 - <html lang="en">
 - <head>
 - <meta charset="UTF-8">
 - <meta name="Author" content="">
 - <meta name="Keywords" content="">
 - <meta name="Description" content="">
 - <meta name="robots"content="noindex,nofollow">
 - <meta http-equiv="refresh"content="3;url=<?php $url=$_GET['url']; echo htmlspecialchars($url);?>">
 - <title>跳转页面</title>
 - <style>
 - .spinner {
 - margin: 100px auto 0;
 - width: 150px;
 - text-align: center;
 - }
 - .spinner > div {
 - width: 30px;
 - height: 30px;
 - border-radius: 100%;
 - display: inline-block;
 - -webkit-animation: bouncedelay 1.4s infinite ease-in-out;
 - animation: bouncedelay 1.4s infinite ease-in-out;
 - /* Prevent first frame from flickering when animation starts */
 - -webkit-animation-fill-mode: both;
 - animation-fill-mode: both;
 - }
 - .spinner .bounce1 {
 - -webkit-animation-delay: -0.32s;
 - animation-delay: -0.32s;
 - background-color: #428bca;
 - }
 - .spinner .bounce2 {
 - -webkit-animation-delay: -0.16s;
 - animation-delay: -0.16s;
 - background-color: #Dd534F;
 - }
 - .spinner .bounce3 {
 - -webkit-animation-delay: -0.01s;
 - animation-delay: -0.01s;
 - background-color: #67CF22;
 - } www.xiariboke.net
 - @-webkit-keyframes bouncedelay {
 - 0%, 80%, 100% { -webkit-transform: scale(0.0) }
 - % { -webkit-transform: scale(1.0) }
 - }
 - @keyframes bouncedelay {
 - 0%, 80%, 100% {
 - transform: scale(0.0);
 - -webkit-transform: scale(0.0);
 - } 40% {
 - transform: scale(1.0);
 - -webkit-transform: scale(1.0);
 - }
 - }
 - </style>
 - </head>
 - <body>
 - <div class="spinner">
 - <div class="bounce1"></div>
 - <div class="bounce2"></div>
 - <div class="bounce3"></div>
 - </div>
 - </body>
 - </html>
 
说明一下,这个页面我们可以自己去diy一下,做成自己喜欢的样子,也可以加些js加载打开页面之类的效果,建好之后,命名为goto.php,放到根目录下,然后我们在万能的function里面加一个钩子就可以了,代码如下:
- /**博客的评论里的外链转内链**/
 - add_filter('get_comment_author_link','add_redirect_comment_link', 5);
 - add_filter('comment_text', 'add_redirect_comment_link', 99);
 - function add_redirect_comment_link($text= ''){
 - $text=str_replace('href="','href="'.get_option('home').'/goto.php?url=', $text);
 - $text=str_replace("href='","href='".get_option('home')."/goto.php?url=", $text); //www.xiariboke.net
 - return$text;
 - }
 
好了,一个简单的wordpress博客评论外链变成跳转的方式了,其实,如果我们单纯的为了避免权重传递的话,常用的方法还有nofollow标签,只要给跳转的网址添加nofollow标签就可以避免权重了,哪种方法合适就看自己怎么使用了。
其实加上这个go跳转功能对站长有利,但是对于访客来说,也许会减少了互动性。nofollow标签就是个很好的选择