WordPress站点增加GO跳转页面详细进程

经常看到一些博客点击外链跳转到其他网站上的时分都会有一个跳转页面,很是美丽。听说是有利于SEO,维护站点权重,不过个人仅仅觉得漂亮、高逼格便加上了 。网上相关的源代码很多,仅仅代码运用的办法不太详尽,关于很多新手小白可能并不友爱,借着这次博客折腾我将把运用办法尽可能地详尽说明,希望可以帮忙新人快速地运用上这个跳转功用。

首要需求说明的是代码来自 AE博客 与 张戈博客 ,代码版权归原作者全部,这儿仅引见运用办法。完结 Go 页面跳转的简单原理是:以往咱们跳转到其他网站是直接拜访该网站的链接;运用 Go 页面跳转后,咱们先拜访本地的 Go 页面(也就是下面 go 文件夹下的 index.php 或直接 go.php文件)然后再跳转到相应的外链网站。

GO 跳转页面代码

将以下代码仿制并保管为一个 index.php 文件丢到网站根目录的 go 文件夹下。

 384 || strpos($_SERVER[\'REQUEST_URI\'], \"eval(\") || strpos($_SERVER[\'REQUEST_URI\'], \"base64\")) {
    @header(\"HTTP/1.1 414 Request-URI Too Long\");
    @header(\"Status: 414 Request-URI Too Long\");
    @header(\"Connection: Close\");
    @exit;
}
//通过QUERY_STRING取得无缺的传入数据,然后取得url=之后的全部值,兼容性更好
$t_url = htmlspecialchars(preg_replace(\'/^url=(.*)$/i\',\'$1\',$_SERVER[\"QUERY_STRING\"]));

//此处可以自定义一些特别的外链,不需求可以删去以下5行
foreach($cars as $k=>$val){
    if($t_url==$val[0] ) {
        $t_url = $val[1];
        $t_vip = 1;
    }
}
 
//数据处置
if(!empty($t_url)) {
    //判别取值能否加密
    if ($t_url == base64_encode(base64_decode($t_url))) {
        $t_url = base64_decode($t_url);
    }
 //对取值停止网址校验和判别
preg_match(\'/^(http|https|thunder|qqdl|ed2k|Flashget|qbrowser):\\/\\//i\',$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 = \'http://\'.$_SERVER[\'HTTP_HOST\'];
        $title=\'参数错误,正在返回主页...\';
    }
}
} else {
    $title = \'参数缺失,正在返回主页...\';
    $url = \'http://\'.$_SERVER[\'HTTP_HOST\'];
}
?>



    
    
    
    <meta http-equiv=\"refresh\" content=\"1;url=\'https://www.zilyun.com/\';\">
    

    
        .ie8 .alert-circle,.ie8 .alert-footer{display:none}.ie8 .alert-box{padding-top:75px}.ie8 .alert-sec-text{top:45px}
    


    
    
        body{margin:0;padding:0;background:#E6EAEB;font-family:Arial,\'微软雅黑\',\'宋体\',sans-serif}.main{position:absolute;left:calc(50% - 200px);top:calc(50% - 13em)}.alert-box{display:none;position:relative;margin:auto;padding:180px 85px 22px;border-radius:10px 10px 0 0;background:#FFF;box-shadow:5px 9px 17px rgba(102,102,102,.75);width:286px;color:#FFF;text-align:center}.alert-box p{margin:0}.alert-circle{position:absolute;top:-50px;left:111px}.alert-sec-circle{stroke-dashoffset:0;stroke-dasharray:735;transition:stroke-dashoffset 1s linear}.alert-sec-text{position:absolute;top:11px;left:190px;width:76px;color:#000;font-size:68px}.alert-sec-unit{font-size:34px}.alert-body{margin:35px 0}.alert-head{color:#242424;font-size:28px}.alert-concent{margin:25px 0 14px;color:#7B7B7B;font-size:18px}.alert-concent p{line-height:27px}.alert-btn{display:block;border-radius:10px;background-color:#4AB0F7;height:55px;line-height:55px;width:286px;color:#FFF;font-size:20px;text-decoration:none;letter-spacing:2px}.alert-btn:hover{background-color:#6BC2FF}.alert-footer{margin:0 auto;height:42px;width:120px}.alert-footer-icon{float:left}.alert-footer-text{float:left;border-left:2px solid #EEE;padding:3px 0 0 5px;height:40px;color:#0B85CC;font-size:12px;text-align:left}.alert-footer-text p{color:#7A7A7A;font-size:22px;line-height:18px}
    


3

一万年太久,分秒必争

<a id=\"js-alert-btn\" class=\"alert-btn\" href=\"https://www.zilyun.com/\">立刻前往
function alertSet(e) { document.getElementById(\"js-alert-box\").style.display = \"block\", document.getElementById(\"js-alert-head\").innerHTML = e; var t = 5, n = document.getElementById(\"js-sec-circle\"); document.getElementById(\"js-sec-text\").innerHTML = t, setInterval(function() { //阻止其他网站调用此跳转 //var MyHOST = new RegExp(\"\"); //if (!MyHOST.test(document.referrer)) { // location.href=\"http://\" + MyHOST; //} if (0 == t) location.href = \"https://www.zilyun.com/\"; else { t -= 1, document.getElementById(\"js-sec-text\").innerHTML = t; var e = Math.round(t / 5 * 735); n.style.strokeDashoffset = e - 735 } }, 970) } alertSet(\"\");

这儿需求说明的是你也可以直接保管为 go.php 丢在网站根目录下,只不过后边修正链接的时分将 go 交换成 go.php 即可。

GO 跳转页面运用

将上述 index.php 文件丢到网站根目录下的 go 文件夹后,咱们既可以通过 http://blog.quietguoguo.com/go/?url=https://www.baidu.com 完结 go 页面跳转了,可是这样每次增加外链都手动增加的话太费事,运用下面的代码既可以完结外链主动增加 http://yourdomain.com/go/?url= :

文章表里链增加go跳转

//文章表里链增加go跳转
function the_content_nofollow($content){
    preg_match_all(\'//\',$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/?url=$val\\\" \",$content);
            }
        }
    }
 return $content;
}
add_filter(\'the_content\',\'the_content_nofollow\',999);

假如你直接将 Go 页面代码保管成 go.php 的话记住改一下上面链接哦~

评论者链接增加go跳转

//评论者链接增加go跳转
function add_redirect_comment_link($text = \'\'){
    $text=str_replace(\'href=\"\', \'href=\"\'.get_option(\'home\').\'/go/?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 页面代码保管成 go.php 的话记住这儿也要改一下链接哦~

普通情况下咱们将站点的这两处链接交换掉就可以了,当然假如你有其他需求只需求想办法将原有外链交换为带有 go/?url= 的就可以了。

资源下载

免费资源本公开载点击下载百度网清点击下载提取码: IQGG仿制留心:本站资源多为网络搜集,如触及版权问题请及时与站长联络,咱们会在榜首时间内与您协商处理。如非特别说明,本站全部资源解压密码均为:zibuyu.life。