有时候你会发现,你在搜索引擎输入网站名称的时候,出来的网站信息是大家的,可是域名倒是一个陌生的,这种状况能够基本肯定网站被镜像了,那么究竟什么叫网站被镜像?javascript
恶意镜像,也叫恶意克隆,恶意解析,是指有人经过域名 A 记录直接解析别人 IP 地址,从而获得一个在访问者眼中彻底相同网站的过程。其工做原理基本上是这样子的:有用户访问镜像站点时,程序就会来正版的站点查询数据,并修改相关连接而后呈献给用户,实质上仍是在读取原站的数据。严谨一点的解释:经过复制整个网站或部分网页内容并分配以不一样域名和服务器,以此欺骗搜索引擎对同一站点或同一页面进行屡次索引的行为 。php
网站被镜像的危害css
通俗的讲,恶意镜像者意图利用本身有必定权重的域名进行威压,经过某些手段复制了你的站点,除了域名不同以外,其余内容如出一辙,用户或许根本没法分辨。甚至对于一些新的站点,搜索引擎都会迷惑到底哪一个是真的站点,那么就有可能正牌的网站被删除收录,而盗版的却被搜索引擎青睐。html
虽然目前咱们还不知道恶意镜像咱们的网站到底有什么意图,但确定对咱们没什么好处,若是他这个域名有点什么不健康的信息,那么咱们被镜像的站点有可能被污染掉,因此仍是要警戒这个现象。vue
如何知道本身的网站是否被镜像java
复制本身网站的完整标题(PS:查看本身站点首页源码,其中 <title>龙笑天下 - 分享悲伤;共享快乐</title>),而后在谷歌和百度等搜索引擎里搜索,如搜索:intitle 龙笑天下 - 分享悲伤;共享快乐,若是有其余网站的网站标题、描述及网站内容跟你的同样,只有域名不同,那就是被镜像了。node
如何处理网站被镜像laravel
这类镜像看似一个完整的站点,其实上是每次用户访问镜像站点,程序就会来正版的站点查询数据,并修改相关连接而后呈献给用户。实质上仍是在读取原站的数据。如下龙笑天下就列举几种解决方法,你们自行取舍使用!web
方法 1:查清镜像网站的主机 Ip,经过禁止 Ip 来解决面试
本教程基于 WordPress 程序,其余系统请自测!
一、获取镜像服务器 ip。注:这个 IP 可能不是 ping 到他域名的 IP
复制以下代码,新建一个 php 文件,并命名为“ip.php”上传到你的网站根目录。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<?php
$file
=
"ip.txt"
;
//保存的文件名
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
$handle
=
fopen
(
$file
,
'a'
);
fwrite(
$handle
,
"IP Address:"
);
fwrite(
$handle
,
"$ip"
);
fwrite(
$handle
,
"\n"
);
fclose(
$handele
);
?>
<?php
$file
=
"ip.txt"
;
//保存的文件名
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
$handle
=
fopen
(
$file
,
'a'
);
fwrite(
$handle
,
"IP Address:"
);
fwrite(
$handle
,
"$ip"
);
fwrite(
$handle
,
"\n"
);
fclose(
$handele
);
?>
|
二、而后访问你网站的镜像站点,在地址后面加.../ip.php,而后你就会在网站根目录找到 ip.txt 文件了,打开复制里面的 ip 地址。
三、而后打开你的.htaccess 文件,在后面加上以下代码(自行修改成刚刚得到的 ip)
1
2
3
4
5
6
7
|
#添加IP黑名单
Order Deny,Allow
Deny from 162.158.72.179
#添加IP黑名单
Order Deny,Allow
Deny from 162.158.72.179
|
固然,若是你使用 CDN,能够直接在 CDN 后台添加 ip 黑名单
这个时候你再刷新一下镜像站点,是否是已经 403 报错了呢?这个时候已经解决了这个镜像站点,而后就等待蜘蛛将其解决掉吧。
此方法的缺点就是若是镜像网站更换了 ip,那咱们的屏蔽就失败了
方法 2:JS 来防御
在头部标签:取自 @boke112 导航
<head></head>
<head></head>
里加上下面的 JS 代码:
1
2
3
4
5
6
7
8
9
10
11
|
<script type=
"text/javascript"
>
if
(document.location.host !=
"www.ilxtx.com"
) {
location.href = location.href.replace(document.location.host,
'www.ilxtx.com'
);
}
</script>
<script type=
"text/javascript"
>
if
(document.location.host !=
"www.ilxtx.com"
) {
location.href = location.href.replace(document.location.host,
'www.ilxtx.com'
);
}
</script>
|
或加上如下的 JS 代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<script type=
"text/javascript"
>
rthost = window.location.host;
if
(rthost !=
"www.ilxtx.com"
) {
}
</script>
<script type=
"text/javascript"
>
rthost = window.location.host;
if
(rthost !=
"www.ilxtx.com"
) {
}
</script>
|
注意:将上面代码中的www.ilxtx.com改成你网站的首页主地址,若是我上面填写的不是我网站的主地址 www.ilxtx.com,而是 ilxtx.com 的话,就会致使网站一直刷新!
注:通过本站测试,若是镜像站屏蔽了 JS,则该方法失效。因此,最好把方法 2 和方法 3 结合使用!
方法 3:Js 被屏蔽后防止镜像的方法
将如下代码加到网站的 header.php 中:代码取自 @boke112
1
2
3
4
5
6
7
8
9
|
<div style=
"display:none;"
>
<script>proxy2016 = false;</script>
<img src=
""
onerror=
'setTimeout(function(){if(typeof(proxy2016)=="undefined"){window.location.host="www.ilxtx.com";}},3000);'
>
</div>
<div style=
"display:none;"
>
<script>proxy2016 = false;</script>
<img src=
""
onerror=
'setTimeout(function(){if(typeof(proxy2016)=="undefined"){window.location.host="www.ilxtx.com";}},3000);'
>
</div>
|
有些网站会屏蔽掉 JS 代码(以下面的代码) :
1
2
|
<script>...</script>
<script>...</script>
|
因此 <script>proxy2016 = false;</script>
代码将被过滤掉,img 的 onerror 设置超时时间 3000 毫秒,将运行函数部分,检测是否还存在 proxy2016 字符,若是没有找到就会将主机的 URL 改成 www.ilxtx.com;为了安全起见,将 js 部分可使用 js 代码混淆(本站“JS 代码混淆” 工具 或 站长之家 JS 混淆工具)。
本站的混淆结果以下:
1
2
3
4
5
6
7
8
9
|
<div style=
"display:none;"
>
<script>proxy2016 = false;</script>
<img src=
" "
onerror=
'setTimeout(function(){if(typeof(proxy2016)=="undefined"){window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x6f\x73\x74"]="\x77\x77\x77\x2e\x69\x6c\x78\x74\x78\x2e\x63\x6f\x6d";}},3000);'
>
</div>
<div style=
"display:none;"
>
<script>proxy2016 = false;</script>
<img src=
" "
onerror=
'setTimeout(function(){if(typeof(proxy2016)=="undefined"){window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x6f\x73\x74"]="\x77\x77\x77\x2e\x69\x6c\x78\x74\x78\x2e\x63\x6f\x6d";}},3000);'
>
</div>
|
通过个人测试,此代码在 Chrome、IE11 和 360 极速浏览器上均有效,会跳转到源站的原文章页!在 Firefox 上则无效果,镜像的文章页并不会跳转到原站...... 将代码中 img 标签的 src 引用地址改成空格或无效的图片地址后,在 Firefox 上也起做用了!
方法 4:借助 Img 的 Onerror 事件
20161119 更新(增长搜狗快照支持):此方法使用了后,会致使百度快照、谷歌快照、必应快照和搜狗快照等跳到 404 页面(360 搜索快照则不会~),奈何不知怎么弄,2016-11-10 再次通过张戈的指导,将原代码中的:if( str1!=str3 )
改成 :if( str1!=str3 && str3!="cache.baiducontent.com" && str3!="webcache.googleusercontent.com" && str3!="c.360webcache.com" && str3!="cncc.bingj.com" && str3!="snapshot.sogoucdn.com" )
。估计要等快照更新时才能知道效果了!
20161127:通过验证,上述更新已经起做用了!具体效果,请点我~
20171022 更新:从张戈那看到,这段代码会由于 onerror 死循环形成浏览网页的电脑高负载(CPU 飙升),所以在代码 onerror 触发事件中加入 onerror 清空机制,即加入this.onerror=null。【博客网页致使电脑 CPU 飙升的问题解决记录】
经过拆分域名连接与镜像站比对,而后用 img 标签 src 空值触发 onerror 来执行 js 比对,比对失败则跳转回源站。
①、WordPress 专用版
通过 @张戈 童学的不断改进(IE 不支持 window.stop() 函数,因此“20160909 版本”失效...),已经完美的适配 Firefox、Chrome、IE11 和 360 极速浏览器,并且能够跳转至源站的相应文章页,在此衷表感谢!下面 3 段任选一个便可。效果请看这里:http://www.ilxtx.com.3s3s.org/the-shawshank-redemption-1994.html
代码以下:(复制粘贴到主题的 functions.php 最后一个?>以前)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
* 最后更新时间:20171022 发布时间:20160912
* 出自:zhangge.net
*/
add_action(
'wp_footer'
,
'lxtx_deny_mirrored_websites'
);
function
lxtx_deny_mirrored_websites(){
$currentDomain
=
'www" + ".ilxtx." + "com'
;
// $currentDomain = '"zhangge." + "net"';
echo
'<img style="display:none" src=" " onerror=\'this.onerror=null;var str1="'
.
$currentDomain
.
'";str2="docu"+"ment.loca"+"tion.host";str3=eval(str2);if( str1!=str3 && str3!="cache.baiducontent.com" && str3!="webcache.googleusercontent.com" && str3!="c.360webcache.com" && str3!="cncc.bingj.com" && str3!="snapshot.sogoucdn.com" ){ do_action = "loca" + "tion." + "href = loca" + "tion.href" + ".rep" + "lace(docu" +"ment"+".loca"+"tion.ho"+"st," + "\"'
.
$currentDomain
.
'\"" + ")";eval(do_action) }\' />'
;
}
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
* 最后更新时间:20171022 发布时间:20160912
* 出自:zhangge.net
*/
add_action(
'wp_footer'
,
'lxtx_deny_mirrored_websites'
);
function
lxtx_deny_mirrored_websites(){
$currentDomain
=
'www" + ".ilxtx." + "com'
;
// $currentDomain = '"zhangge." + "net"';
echo
'<img style="display:none" src=" " onerror=\'this.onerror=null;var str1="'
.
$currentDomain
.
'";str2="docu"+"ment.loca"+"tion.host";str3=eval(str2);if( str1!=str3 && str3!="cache.baiducontent.com" && str3!="webcache.googleusercontent.com" && str3!="c.360webcache.com" && str3!="cncc.bingj.com" && str3!="snapshot.sogoucdn.com" ){ do_action = "loca" + "tion." + "href = loca" + "tion.href" + ".rep" + "lace(docu" +"ment"+".loca"+"tion.ho"+"st," + "\"'
.
$currentDomain
.
'\"" + ")";eval(do_action) }\' />'
;
}
|
Ps:若是是丢到 wp_head,通过测试发现图片放到 head,浏览器会自动进行错误调整,致使一些原本在 head 的元素被丢到了 body 当中,好比 style.css,估计网页标准中 head 里面就不该该放置图片,因此移到了 footer 当中。
1
2
3
4
5
6
7
8
9
10
11
|
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
* 出自:zhangge.net
*/
add_action(
'wp_footer'
,
'lxtx_deny_mirrored_websites'
);
function
lxtx_deny_mirrored_websites(){
$currentDomain
=
"www' + '.ilxtx.' + 'com"
;
// $currentDomain = "zhangge' + '.' + 'net";
echo
'<img style="display:none" src="nothing" onerror="this.onerror=null;var str1=\''
.
$currentDomain
.
'\';str2=\'docu\'+\'ment.loca\'+\'tion.host\';str3=eval(str2);if( str1!=str3 ){ do_action = \'loca\' + \'tion.\' + \'href = loca\' + \'tion.href\' + \'.rep\' + \'lace(docu\' +\'ment\'+\'.loca\'+\'tion.ho\'+\'st,\' + \'\\\''
.
$currentDomain
.
'\\\'\' + \')\';eval(do_action) }" />'
;
}
|
1
2
3
4
5
6
7
8
9
10
|
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
* zhangge.net修改
*/
add_action(
'wp_footer'
,
'lxtx_kimsom_reverse_proxy_defense'
, 99);
function
lxtx_kimsom_reverse_proxy_defense(){
$currentDomain
=
'"www." + "ilxtx" + ".com"'
;
echo
'<img style="display:none" id="inlojv-rpd" src="nothing" data-url="'
.home_url().
'" onerror=\'this.onerror=null;var str0=document.getElementById("inlojv-rpd").attributes.getNamedItem("data-url").nodeValue;var ishttps="https:"==document.location.protocol?true:false;if(ishttps){var str1="https"+"://";}else{var str1="http"+"://";}var str2='
.
$currentDomain
.
';var str3=str1+str2;if( str0!=str3 ){location.href = location.href.replace(document.location.host,'
.
$currentDomain
.
');}\'/>'
;
}
|
Tips:若是想像“20160909 版本”同样有个提示语,可将上面这段代码改成此
1
2
3
4
5
|
add_action(
'wp_footer'
,
'lxtx_kimsom_reverse_proxy_defense'
, 99);
function
lxtx_kimsom_reverse_proxy_defense(){
$currentDomain
=
'"www." + "ilxtx" + ".com"'
;
echo
'<img style="display:none" id="inlojv-rpd" src="nothing" data-url="'
.home_url().
'" onerror=\'this.onerror=null;var str0=document.getElementById("inlojv-rpd").attributes.getNamedItem("data-url").nodeValue;var ishttps="https:"==document.location.protocol?true:false;if(ishttps){var str1="https"+"://";}else{var str1="http"+"://";}var str2='
.
$currentDomain
.
';var str3=str1+str2;if( str0!=str3 ){alert("\u8b66\u544a\uff01\u68c0\u6d4b\u5230\u8be5\u7f51\u7ad9\u4e3a\u6076\u610f\u955c\u50cf\u7ad9\u70b9\uff0c\u5c06\u7acb\u5373\u4e3a\u60a8\u8df3\u8f6c\u5230\u5b98\u65b9\u7ad9\u70b9\uff01");location.href = location.href.replace(document.location.host,'
.
$currentDomain
.
');}\'/>'
;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
摘自 @曾劲松博客
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
*/
add_action(
'wp_footer'
,
'lxtx_kimsom_reverse_proxy_defense'
);
function
lxtx_kimsom_reverse_proxy_defense(){
$domain_arr
=
explode
(
'//'
,home_url());
$domain
=
$domain_arr
[1];
echo
'<img style="display:none" id="inlojv-rpd" src="nothing" data-url="'
.home_url().
'" onerror="this.onerror=null;var str0=document.getElementById(\'inlojv-rpd\').attributes.getNamedItem(\'data-url\').nodeValue;var ishttps=\'https:\'==document.location.protocol?true:false;if(ishttps){var str1=\'https\'+\'://\';}else{var str1=\'http\'+\'://\';}var str2=\''
.
$domain
.
'\';var str3=str1+str2;if( str0!=str3 ){alert(\'\u8b66\u544a\uff01\u68c0\u6d4b\u5230\u8be5\u7f51\u7ad9\u4e3a\u6076\u610f\u955c\u50cf\u7ad9\u70b9\uff0c\u5c06\u7acb\u5373\u4e3a\u60a8\u8df3\u8f6c\u5230\u5b98\u65b9\u7ad9\u70b9\uff01\');if (!!(window.attachEvent && !window.opera)){document.execCommand(\'stop\');}else{ window.stop();}var str4=\'wind\'+\'ow.loca\'+\'tion.rep\'+\'lace(str3)\';eval(str4);}">'
;
}
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
*/
add_action(
'wp_footer'
,
'lxtx_kimsom_reverse_proxy_defense'
);
function
lxtx_kimsom_reverse_proxy_defense(){
$domain_arr
=
explode
(
'//'
,home_url());
$domain
=
$domain_arr
[1];
echo
'<img style="display:none" id="inlojv-rpd" src="nothing" data-url="'
.home_url().
'" onerror="this.onerror=null;var str0=document.getElementById(\'inlojv-rpd\').attributes.getNamedItem(\'data-url\').nodeValue;var ishttps=\'https:\'==document.location.protocol?true:false;if(ishttps){var str1=\'https\'+\'://\';}else{var str1=\'http\'+\'://\';}var str2=\''
.
$domain
.
'\';var str3=str1+str2;if( str0!=str3 ){alert(\'\u8b66\u544a\uff01\u68c0\u6d4b\u5230\u8be5\u7f51\u7ad9\u4e3a\u6076\u610f\u955c\u50cf\u7ad9\u70b9\uff0c\u5c06\u7acb\u5373\u4e3a\u60a8\u8df3\u8f6c\u5230\u5b98\u65b9\u7ad9\u70b9\uff01\');if (!!(window.attachEvent && !window.opera)){document.execCommand(\'stop\');}else{ window.stop();}var str4=\'wind\'+\'ow.loca\'+\'tion.rep\'+\'lace(str3)\';eval(str4);}">'
;
}
|
添加以上代码以后,再打开镜像站就会弹出提示:“警告!检测到该网站为恶意镜像站点,将当即为您跳转到官方站点!”,并在关闭或肯定此提示后直接跳转到被镜像的网站。通过本站测试,本方法防止网站被镜像目前有效。
效果请看这里:
https://www.ilxtx.com.dijicat.com/the-shawshank-redemption-1994.html
此方法在 IE11 上,会弹出提示框,但点击“肯定”按钮后,网页并不会跳转。。。Firefox、Chrome 和 360 极速浏览器上则没此问题!
②、HTML 通用版
既然是利用 js 代码,那么就能用到如何 html 页面当中了。要不是为了能够放到 wp 的 functions.php,都不必写成 php 的模式,直接用 html 代码便可:
1
2
3
|
<img style=
"display:none"
src=
" "
onerror=
'this.onerror=null;var currentDomain="www." + "ilxtx" + ".com"; var str1=currentDomain; str2="docu"+"ment.loca"+"tion.host"; str3=eval(str2) ;if( str1!=str3 && str3!="cache.baiducontent.com" && str3!="webcache.googleusercontent.com" && str3!="c.360webcache.com" && str3!="cncc.bingj.com" && str3!="snapshot.sogoucdn.com" ){ do_action = "loca" + "tion." + "href = loca" + "tion.href" + ".rep" + "lace(docu" +"ment"+".loca"+"tion.ho"+"st," + "currentDomain" + ")";eval(do_action) }'
/>
<img style=
"display:none"
src=
" "
onerror=
'this.onerror=null;var currentDomain="www." + "ilxtx" + ".com"; var str1=currentDomain; str2="docu"+"ment.loca"+"tion.host"; str3=eval(str2) ;if( str1!=str3 && str3!="cache.baiducontent.com" && str3!="webcache.googleusercontent.com" && str3!="c.360webcache.com" && str3!="cncc.bingj.com" && str3!="snapshot.sogoucdn.com" ){ do_action = "loca" + "tion." + "href = loca" + "tion.href" + ".rep" + "lace(docu" +"ment"+".loca"+"tion.ho"+"st," + "currentDomain" + ")";eval(do_action) }'
/>
|
将以上代码中的: var currentDomain="www." + "ilxtx" + ".com";
自行拆分红本身的域名,避免被镜像代码替换掉,好比: var currentDomain="zhangge." + "net";
而后将代码添加到网站的 <body> 以后便可(不建议放置到 <head> 里面,具体缘由上文已说明),这个版本适合任何网页。
方法 5:经过禁止某些 User Agent 特征来防
服务器反爬虫攻略:Apache/Nginx/PHP 禁止某些 User Agent 抓取网站
咱们都知道网络上的爬虫很是多,有对网站收录有益的,好比百度蜘蛛(Baiduspider),也有不但不遵照 robots 规则对服务器形成压力,还不能为网站带来流量的无用爬虫,好比 YY 蜘蛛(Yis...
参考上面这篇文章来禁止 UA 为 PHP 的抓取网页,从而达到防镜像的目的!
①、PHP 通用版:
将下面的代码贴到网站入口文件 index.php 中的第一个 <?php以后便可:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
//防止恶意HTTP_USER_AGENT采集
$ua
=
$_SERVER
[
'HTTP_USER_AGENT'
];
$now_ua
=
array
(
'FeedDemon '
,
'BOT/0.1 (BOT for JCE)'
,
'CrawlDaddy '
,
'Java'
,
'Feedly'
,
'UniversalFeedParser'
,
'ApacheBench'
,
'Swiftbot'
,
'ZmEu'
,
'Indy Library'
,
'oBot'
,
'jaunty'
,
'YandexBot'
,
'AhrefsBot'
,
'MJ12bot'
,
'WinHttp'
,
'EasouSpider'
,
'HttpClient'
,
'Microsoft URL Control'
,
'YYSpider'
,
'jaunty'
,
'Python-urllib'
,
'lightDeckReports Bot'
,
'PHP'
);
if
(!
$ua
) {
header(
"Content-type: text/html; charset=utf-8"
);
die
(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
else
{
foreach
(
$now_ua
as
$value
)
if
(
eregi
(
$value
,
$ua
)) {
header(
"Content-type: text/html; charset=utf-8"
);
die
(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
}
//防止恶意HTTP_USER_AGENT采集
$ua
=
$_SERVER
[
'HTTP_USER_AGENT'
];
$now_ua
=
array
(
'FeedDemon '
,
'BOT/0.1 (BOT for JCE)'
,
'CrawlDaddy '
,
'Java'
,
'Feedly'
,
'UniversalFeedParser'
,
'ApacheBench'
,
'Swiftbot'
,
'ZmEu'
,
'Indy Library'
,
'oBot'
,
'jaunty'
,
'YandexBot'
,
'AhrefsBot'
,
'MJ12bot'
,
'WinHttp'
,
'EasouSpider'
,
'HttpClient'
,
'Microsoft URL Control'
,
'YYSpider'
,
'jaunty'
,
'Python-urllib'
,
'lightDeckReports Bot'
,
'PHP'
);
if
(!
$ua
) {
header(
"Content-type: text/html; charset=utf-8"
);
die
(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
else
{
foreach
(
$now_ua
as
$value
)
if
(
eregi
(
$value
,
$ua
)) {
header(
"Content-type: text/html; charset=utf-8"
);
die
(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
}
|
②、Wordpress 适用版
若是使用上面的 php 版本,WordPress 每次更新就会须要操做 index.php,比较麻烦,所以弄个专版。
将下面的代码贴到 functions.php 中的最后一个 ?>以前便可:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
* 出自:zhange.net
*/
//防止恶意HTTP_USER_AGENT采集
add_action(
'wp_head'
,
'lxtx_deny_mirrored_request'
, 0);
function
lxtx_deny_mirrored_request()
{
$ua
=
$_SERVER
[
'HTTP_USER_AGENT'
];
$now_ua
=
array
(
'FeedDemon '
,
'BOT/0.1 (BOT for JCE)'
,
'CrawlDaddy '
,
'Java'
,
'Feedly'
,
'UniversalFeedParser'
,
'ApacheBench'
,
'Swiftbot'
,
'ZmEu'
,
'Indy Library'
,
'oBot'
,
'jaunty'
,
'YandexBot'
,
'AhrefsBot'
,
'MJ12bot'
,
'WinHttp'
,
'EasouSpider'
,
'HttpClient'
,
'Microsoft URL Control'
,
'YYSpider'
,
'jaunty'
,
'Python-urllib'
,
'lightDeckReports Bot'
,
'PHP'
);
if
(!
$ua
) {
header(
"Content-type: text/html; charset=utf-8"
);
wp_die(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
else
{
foreach
(
$now_ua
as
$value
)
if
(
eregi
(
$value
,
$ua
)) {
header(
"Content-type: text/html; charset=utf-8"
);
wp_die(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
}
}
/**
* 网站被恶意镜像怎么办 一段代码轻松搞定(全面版) - 龙笑天下
* 出自:zhange.net
*/
//防止恶意HTTP_USER_AGENT采集
add_action(
'wp_head'
,
'lxtx_deny_mirrored_request'
, 0);
function
lxtx_deny_mirrored_request()
{
$ua
=
$_SERVER
[
'HTTP_USER_AGENT'
];
$now_ua
=
array
(
'FeedDemon '
,
'BOT/0.1 (BOT for JCE)'
,
'CrawlDaddy '
,
'Java'
,
'Feedly'
,
'UniversalFeedParser'
,
'ApacheBench'
,
'Swiftbot'
,
'ZmEu'
,
'Indy Library'
,
'oBot'
,
'jaunty'
,
'YandexBot'
,
'AhrefsBot'
,
'MJ12bot'
,
'WinHttp'
,
'EasouSpider'
,
'HttpClient'
,
'Microsoft URL Control'
,
'YYSpider'
,
'jaunty'
,
'Python-urllib'
,
'lightDeckReports Bot'
,
'PHP'
);
if
(!
$ua
) {
header(
"Content-type: text/html; charset=utf-8"
);
wp_die(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
else
{
foreach
(
$now_ua
as
$value
)
if
(
eregi
(
$value
,
$ua
)) {
header(
"Content-type: text/html; charset=utf-8"
);
wp_die(
'请勿采集本站,采集者木有小JJ!请正常访问,并认准【龙笑天下网】官方网址!'
);
}
}
}
|
通过测试,在 functions.php 中加入此代码后,打开镜像站后显示“Internal Server Error”,强制刷新后显示咱们设置好的提示文字“请勿采集本站,采集者木有小 JJ!请正常访问,并认准【龙笑天下网】官方网址!”。
本站目前发现的恶意镜像域名
dijicat.com
lapaleo.com
iaroex.com
disauvi.com
3s3s.org
ytlqpo.com
s3.gvirabi.com
hdtmail.com
dimyapi.com
更多镜像网站等你提供~
在这些域名前面加上大家本身的的域名,看看有没有被恶意镜像。
友情提示:建议方法 2 和方法 3 一块儿使用!方法 4 包含方法 2 和方法 3~