简单漂亮的go外链跳转 建站

zsxwz 20/03.28 10:44 822


不管是为了seo优化,或者方便加广告之类的,外链跳转,对于建站而言,有时候还是挺好用的。


新建一个go.php


在链接之前加:

https://bbs.zsxwz.com/go.php?url=

即可实现跳转。


<?php
$t_url=$_GET['url'];
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://bbs.zsxwz.com/';
$title='参数错误,正在返回首页...';
}
}
} else {
$title='参数缺失,正在返回首页...';
$url='https://bbs.zsxwz.com/';
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="5;url='<?php echo $url;?>';">
<title><?php echo $title;?></title>
<div id="circle"></div>
<div id="circletext"></div>
<div id="circle1"></div>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="1;url='<?php echo $url;?>';">
<title><?php echo $title;?></title>
<style>
<style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}body{background:#3498db;}#loader-container{width:188px;height:188px;color:white;margin:0 auto;position:absolute;top:50%;left:50%;margin-right:-50%;transform:translate(-50%,-50%);border:5px solid #3498db;border-radius:50%;-webkit-animation:borderScale 1s infinite ease-in-out;animation:borderScale 1s infinite ease-in-out;}#loadingText{font-family:'Raleway',sans-serif;font-size:1.4em;position:absolute;top:50%;left:50%;margin-right:-50%;transform:translate(-50%,-50%);}@-webkit-keyframes borderScale{0%{border:5px solid white;}50%{border:25px solid #3498db;}100%{border:5px solid white;}}@keyframes borderScale{0%{border:5px solid white;}50%{border:25px solid #3498db;}100%{border:5px solid white;}}
</style>
</style></head>
<body>
<div id="loader-container"><p id="loadingText">页面加载中...</p></div>
</body>
</html>


博客网站用的是wordpress,虽然加了go跳转,但没有用这个源码。

需要在functions.php,中加入:

add_filter('the_content','the_content_nofollow',999);
    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/?url=$val\" ",$content);
                }
            }
        }
        return $content;
    }


论坛就比较简单粗暴了,配合文件链接转超链接,直接加到了所有链接上了,比较方便的是,发帖不管你发链接是不是超链接,最后都是超链接。



上一篇:github下载加速油猴脚本版
下一篇:cloudreve支持多家云存储的网盘系统
最新回复 (1)
  • zxcctv22 0
    引用 2
    kuyunzy457878
    20/07.20 01:29 0 回复
    • 姿势论坛—姿势小王子
      3
返回
发新帖
友情链接
免责声明:本站部分资源来源于网络,如有侵权请发邮件(mail@zsxwz.com)告知我们,我们将会在24小时内处理。