屏蔽国外IP地址访问国内网站方法
JS脚本大法:
<script language="javascript"> <!-- var lang = navigator.language || navigator.userLanguage; if(lang.substr(0, 3) == "zh-") ; else location = "/404.html"; //--> </script>
PHP大法:
<?php if(preg_match('/zh\-cn/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'])) exit; ?>
或
<?php if(preg_match("/^zh-cn/i",$_SERVER["HTTP_ACCEPT_LANGUAGE"])) exit; ?>
静态HTML
.htaccess
RewriteEngine On RewriteRule *.html ifcn.php
ifcn.php
<?php if(!preg_match('/zh\-cn/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'])) echo file_get_contents(preg_replace('/^\//','',$_SERVER['REQUEST_URI'])); ?>
评论