修改步骤:
1.打开wp-includes文件夹下的comment-template.php文件
2.找到这句:
$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
3.链接修改为:
$return = "<a href='/redirect/?$url' rel='external nofollow ugcc' target='_blank' class='url'>$author</a>";
4.主目录添加redirect
目录,新建index.php文件,添加代码:
<?php
//$t_url=$_GET['url']; //此代码无法支持带请求参数的目的地址,已弃用!
$t_url = preg_replace('/^url=(.*)$/i','$1',$_SERVER["QUERY_STRING"]); //这个支持
if(!empty($t_url)) {
preg_match('/(http|https):\/\//',$t_url,$matches);
if($matches){
$url=$t_url;
$title='页面加载中,请稍候...';
} else {
preg_match('/\./i',$t_url,$matche);
if($matche){
$url='http://'.$t_url;
$title='页面加载中,请稍候...';
} else {
$url='https://www.xunlu.net/';
$title='参数错误,正在返回首页...';
}
}
} else {
$title='参数缺失,正在返回首页...';
$url='https://www.xunlu.net/';
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="0;url='<?php echo $url;?>';">
<title><?php echo $title;?></title>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?55aa13c233e22ecc157852a092fbda11";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body>
<!--<div class="loading">-->
<!-- <div class="spinner-wrapper">-->
<!-- <span class="spinner-text">页面加载中,请稍候...</span>-->
<!-- <span class="spinner"></span>-->
<!-- </div>-->
<!--</div>-->
</body>
</html>