有时你的网站不想某个国家的IP访问,Blockacountry可帮助你屏蔽这些国家的IP地址访问你的网站,不需要自己动手写程序,也不需要去找出各国IP地址段,通过这个Blockacountry,选择要屏蔽的国家,按下“Generate my blocking file”就会生成一段代码,把它复制到.htaccess文件里,上传到你的空间就可以了。没有用过或听过htsccess文件的,看这里:http://www.lxvoip.net/other-resources/htaccess-maker.html
地址:http://www.blockacountry.com
上面的原理是通过.htaccess文件来屏蔽访问者的IP,另一方法也可通过屏蔽中文操作系统,如果不是中国,把zh-ch换下就可以,代码如下:
$client_sys_language = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; // system language
if (preg_match (“/^zh-cn/i”,$client_sys_language)) {
echo ”
Forbidden
You don’t have permission to access /on this server.Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
www.lxvoip.net Port 80
“;
exit;
}