添加以下代码到functions.php文件
//评论者链接的网址重定向跳转 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="', 'target="_blank" href="'.get_option('home').'/go.php?url=', $text); $text=str_replace("href='", "target='_blank'href='".get_option('home')."/go.php?url=", $text); return $text; } add_action('init', 'redirect_comment_link'); function redirect_comment_link(){ $redirect = $_GET['url']; $redirect = trim(str_replace("\r","",str_replace("\r\n","",strip_tags(str_replace("'","",str_replace("\n", "", str_replace(" ","",str_replace("\t","",trim($redirect))))),"")))); $host = $_SERVER['HTTP_HOST']; if($redirect){ if(strpos($_SERVER['HTTP_REFERER'],get_option('home')) !== false){ header("Location: $redirect#from:$host"); exit; } else { header("Location: $redirect#from:$host"); exit; } } }
然后上传go.php文件和safe.php文件到博客程序根目录。
其中go.php是跳转页面,safe.php是防护脚本。
关于跳转:
方案一是直接跳转,下载包里有。
方案二是带有跳转页面,如本博客就是,这里提供了两个风格,下载包里有,请选取一个即可,也可自己制作。
最后附加安全小提示:为了更进一步避免被检测到有跨站漏洞请在404模板的最开头添加下面一句代码,(前提是上传了safe.php)
- <!--?require_once('safe.php');?-->
如果测试的时候编码出错就修改下go.php的编码!
下载
BZ,为什么要转跳一下呢?
@Soar、毅 ==装逼用~