boxmoe_header_banner_img

Hello! 欢迎来到小寂博客!

加载中

文章导读

本站自用外链跳转页面go.php源码


avatar
嘉木 2020-04-19 11

结合了张戈提供的go.php

Nginx伪静态设置

网站配置里面加入以下代码

[v_act]#外链跳转伪静态php版本
rewrite ^/go/(.*)$ /go.php?url=$1 last; #注意go.php的实际路径,默认为网站根目录[/v_act]

WordPress替换

在主题的functions.php文件里加入以下代码

//文章外链跳转伪静态版
add_filter('the_content','link_jump',999);
function link_jump($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) && !preg_match('/(ed2k|thunder|Flashget|flashget|qqdl):\/\//i',$val)){
	        $content=str_replace("href=\"$val\"", "href=\"".home_url()."/go/".base64_encode($val)."\" rel=\"nofollow\"",$content);
			}
		}
	}
	return $content;
}

[dl href='https://darkt-10057312.file.myqcloud.com/img/2020/04/34d1f91fb2e514b.zip']GO.PHP源码下载[/dl]



评论(0)

查看评论列表

暂无评论


发表评论

表情 颜文字

插入代码