向来都有去百度统计查看的习惯,今日不料被我发现一个坏东西竟然镜像,实在可恶! 然后心里一笑本宝宝辣么荣幸,还有镜像本站的。随之就去各种询问...终于找到了好几个比较简单粗暴的.. 接下来给你们分享一下这几种使用简单粗暴的防镜像神器,个人觉得放在底部文件footer.PHP比较合适其余不多说直接上代码。。 JS版本<script type="text/javascript"> if(location.toString().indexOf("moqu8.com")<=-1){document.location.href="https://www.moqu8.com ";} </script> <script> if (document.domain != 'www.moqu8.com'){ window.location.href='https://www.moqu8.com/';} </script> <script type="text/javascript"> if (document.location.protocol != "https:" && navigator.userAgent.indexOf("MSIE 6.0") < 0 ) { location.href = location.href.replace(/^http:/,"https:");}if (document.location.host != "www.moqu8.com") { location.href = location.href.replace(document.location.host,'www.moqu8.com);} </script> <script type="text/javascript"> if (document.location.host != "www.moqu8.com") { location.href = location.href.replace(document.location.host,'www.moqu8.com'); } </script> JS代码被屏蔽后解决方法<div style="display:none;"> <script>proxy2016 = false;</script> <img src=" " onerror='setTimeout(function(){if(typeof(proxy2016)=="undefined"){window.location.host="moqu8.com";}},3000);'> </div> PHP通用版本将下面的代码贴到网站入口文件index.php中的第一个 <?php之后即可: //防止恶意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!请正常访问!');
}
} 复制代码后记得更换域名! |
2024-03-16 | 魔趣吧站长
2024-03-16 | 魔趣吧站长
2024-03-16 | 魔趣吧站长
2023-05-09 | 魔趣吧站长