仅代码实现WordPress内容外链Base64加密外链转内链跳转
导读:老蒋看到不少的网友博客外链接看不到明链,全部是加密过的。这个应该是传说中的Base64加密方式。可以将外部的链接加密成内链,这样一来可以隐藏地址URL,二来可以内链权重不至于流失,那这种是如何实现的呢?这里老蒋已经测试成功的项目中把代码巴拉...
老蒋看到不少的网友博客外链接看不到明链,全部是加密过的。这个应该是传说中的Base64加密方式。可以将外部的链接加密成内链,这样一来可以隐藏地址URL,二来可以内链权重不至于流失,那这种是如何实现的呢?这里老蒋已经测试成功的项目中把代码巴拉下来。
第一、Functions.php部分
//自动给文章的外部链接添加nofollow属性add_filter('the_content','web589_the_content_nofollow',999);
function web589_the_content_nofollow($content){
preg_match_all('/href="(http.*?)"/',$content,$matches);
if($matches){
foreach($matches[1] as $val){
if( strpos($val,home_url())===false ) $content=str_replace("href=\"$val\"", "rel=\"nofollow\" href=\"" . get_bloginfo('wpurl'). "/go?url=" .base64_encode($val). "\"",$content);
}
}
return $content;
}
这里需要添加到我们的主题Functions.php文件中。
2、单独页面代码
我们在网站根目录创建一个 go 目录,然后创建一个index.php文件,然后代码用下面的。
?php $url = $_GET['url'];
$a = '';
if( $a==$url ) {
$b = "https://www.itbulu.com/";
// echo 'true';
}
else {
$b = $url;
$b = base64_decode($b);
}
//Template Name:链接跳转(有过度)?>
html>
head>
meta charset=utf-8 />
meta name="robots" content="nofollow">
meta http-equiv="refresh" content="0.1;
url=?php echo $b;
?>
">
title>
正在为您跳转……/title>
style>
body{
background:#000}
.loading{
-webkit-animation:fadein 2s;
-moz-animation:fadein 2s;
-o-animation:fadein 2s;
animation:fadein 2s}
@-moz-keyframes fadein{
from{
opacity:0}
to{
opacity:1}
}
@-webkit-keyframes fadein{
from{
opacity:0}
to{
opacity:1}
}
@-o-keyframes fadein{
from{
opacity:0}
to{
opacity:1}
}
@keyframes fadein{
from{
opacity:0}
to{
opacity:1}
}
.spinner-wrapper{
position:absolute;
top:0;
left:0;
z-index:300;
height:100%;
min-width:100%;
min-height:100%;
background:rgba(255,255,255,0.93)}
.spinner-text{
position:absolute;
top:41.5%;
left:47%;
margin:16px 0 0 35px;
color:#BBB;
letter-spacing:1px;
font-weight:700;
font-size:9px;
font-family:Arial}
.spinner{
position:absolute;
top:40%;
left:45%;
display:block;
margin:0;
width:1px;
height:1px;
border:25px solid rgba(100,100,100,0.2);
-webkit-border-radius:50px;
-moz-border-radius:50px;
border-radius:50px;
border-left-color:transparent;
border-right-color:transparent;
-webkit-animation:spin 1.5s infinite;
-moz-animation:spin 1.5s infinite;
animation:spin 1.5s infinite}
@-webkit-keyframes spin{
0%,100%{
-webkit-transform:rotate(0deg) scale(1)}
50%{
-webkit-transform:rotate(720deg) scale(0.6)}
}
@-moz-keyframes spin{
0%,100%{
-moz-transform:rotate(0deg) scale(1)}
50%{
-moz-transform:rotate(720deg) scale(0.6)}
}
@-o-keyframes spin{
0%,100%{
-o-transform:rotate(0deg) scale(1)}
50%{
-o-transform:rotate(720deg) scale(0.6)}
}
@keyframes spin{
0%,100%{
transform:rotate(0deg) scale(1)}
50%{
transform:rotate(720deg) scale(0.6)}
}
/style>
/head>
body>
div class="loading">
div class="spinner-wrapper">
span class="spinner-text">
加载中.../span>
span class="spinner">
/span>
/div>
/div>
/body>
/html>
这里我们需要将文章中开始的 itbulu.com 换成我们自己的网址。
这样,我们再去试试看。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 仅代码实现WordPress内容外链Base64加密外链转内链跳转
本文地址: https://pptw.com/jishu/665506.html