当网站被人镜像时,可以试试往程序里增加防镜像代码。 <script type="text/javascript"> rthost = window.location.host; if (rthost != "www.yudilu.com") { top.location.href = "http://www.yudilu.com"; } demo = false; </script> <div style="display:none;"> <img src="" onerror='setTimeout(function(){if(typeof(demo)=="undefined"){window.location.href="www.yudilu.com";}},1000);'> </div> 由于有些镜像网站采集时会过滤掉JS和一些代码,故上面蓝色字代码可以进行“js代码混淆”处理下(在线js代码混淆网址:http://tool.chinaz.com/tools/jscodeconfusion.aspx),降低被过滤的可能性。 混淆后代码如: <div style="\x64\x69\x73\x70\x6c\x61\x79\x3a\x6e\x6f\x6e\x65\x3b"><img src="" onerror='\x73\x65\x74\x54\x69\x6d\x65\x6f\x75\x74\x28\x66\x75\x6e\x63\x74\x69\x6f\x6e\x28\x29\x7b\x69\x66\x28\x74\x79\x70\x65\x6f\x66\x28\x64\x65\x6d\x6f\x29\x3d\x3d\x22\x75\x6e\x64\x65\x66\x69\x6e\x65\x64\x22\x29\x7b\x77\x69\x6e\x64\x6f\x77\x2e\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x2e\x68\x72\x65\x66\x3d\x22\x77\x77\x77\x2e\x79\x75\x64\x69\x6c\x75\x2e\x63\x6f\x6d\x22\x3b\x7d\x7d\x2c\x31\x30\x30\x30\x29\x3b'></div> 这样混淆后所有代码是: <script type="text/javascript"> rthost = window.location.host; if (rthost != "www.yudilu.com") { top.location.href = "http://www.yudilu.com"; } demo = false; </script> <script type="\x74\x65\x78\x74\x2f\x6a\x61\x76\x61\x73\x63\x72\x69\x70\x74">rthost = window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x6f\x73\x74"];if (rthost != "\x77\x77\x77\x2e\x79\x75\x64\x69\x6c\x75\x2e\x63\x6f\x6d") { top["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x72\x65\x66"] = "\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x79\x75\x64\x69\x6c\x75\x2e\x63\x6f\x6d";}demo = false;</script>
当网站被人镜像时,可以试试该解决方法
未经允许不得转载:阿强爱分享 » 当网站被人镜像时,可以试试该解决方法