防止被代理
海盗湾一火,没想到自个的网站也被反代,害处就是会被百度、谷哥认为作弊,从而封杀你。毒害不容小觑。
分四个层面封杀:
1、防火墻
先封杀对方的IP:
iptables -I INPUT -s 94.242.59.146 -j DROP
service iptables save
2、web服務器
server { listen 80;
server_name hdwo.net;
root /home/www/;
charset utf-8;
set $deny 1;
if($host = "www.hdwo.net"){
set $deny 0;
}
if($host = "hdwo.net"){
set $deny 0;
}
if($deny = 1){
return 404;
}
3、JS跳转:
JS放在header.php <body>上面:
<script type="text/javascript">
if (top.location != self.location)top.location=self.location;
if (document.domain != 'hdwo.net' && document.domain != 'www.hdwo.net'){
window.location.href='http://hdwo.net/';
}
</script>
在</header>后面加上:
<base href="http://hdwo.net" />
4、PHP
PHP代码放在/index.php最上面:
<?php
if($_SERVER['SERVER_NAME'] != 'hdwo.net' && $_SERVER['SERVER_NAME'] != 'www.hdwo.net' )
{
exit('<script>window.location.href="http://hdwo.net";</script>');
}