兜兜转转,回归初恋,欢迎使用yusiyuhuo主题, 主题介绍>>>

淘宝客外链转内链专用

WordPress建站 陌小雨 6164℃ 0评论

之前分享过陌小雨博客导航外链跳转代码,今天又看到了一个base加密的外链转内链淘宝客专用的方法,分享给大家,按需选择吧。

1、复制代码到主题functions.php文件中

/外部链接url跳转
add_filter(‘the_content’,’dmeng_the_go_url’,999);
function dmeng_the_go_url($content){
preg_match_all(‘/href=”(.*)”/’,$content,$matches);
if($matches){
foreach($matches[1] as $val){
if( strpos($val,home_url())===false ) $content=str_replace(“href=\”$val\””, “href=\”” . get_bloginfo(‘template_url’). “/gourl=” .base64_encode($val). “\””,$content);
}
}
return $content;
}

然后在主题根目录下新建一个 go 目录,并在该目录下新建一个内容如下的index.php文件,代码如下

<?php
$url = $_GET[‘url’];
$url = base64_decode($url);
>
<html lang=”zh-CN”>
<head>
<meta charset=utf-8 />
<meta http-equiv=”refresh” content=”0.1;url=<?php echo $url; ?>”>
<title>跳转页</title>
</head>
<body>
</body>
</html>

需要把文件保存为UTF-8格式编码。

同样,如果你不喜欢代码,可以使用插件anylink,全自动替换,也可手动指定。

 

转载请注明:小雨科技 _武汉网站建设_武汉小程序搭建 » 淘宝客外链转内链专用

喜欢 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址