2012-01-05 111 views
-1

我想阻止网站被视为不存在某个地区。这可能吗?从IP或地区块访问网站

我知道我们可以放一个die()并显示一个空白页面,但有没有办法让它看起来像这个域不存在?

+0

为什么? ww =全球范围内,区域阻塞是平均值。 – 2012-01-05 05:18:25

+0

更不用说如果整个国家的用户被视为一个IP,即ISP的IP,您将阻止整个国家! – Joseph 2012-01-05 08:03:09

回答

1

您可以使用apache的geoip mod(http://www.maxmind.com/app/mod_geoip)。 Mod_rewrite规则可以决定如何处理页面。

RewriteEngine on 
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$ 
RewriteRule ^(.*)$ http://www.america.com$1 [F] 

歼禁止页面访问

0

不,除非你有你的控制下,该域的DNS服务器。你通常不会为domain.tld这样的域名,你只能根据客户端ip调整内容 - 例如你可以按照你的建议提供一个空白页面。但是仍然可以使用nslookup等工具查询域。

0

如果您无权访问DNS服务器,则可以添加.htaccess规则以禁止来自特定ipaddresses的用户。以下是一些样品的.htaccess规则

order allow,deny 
deny from 123.456.789.012  #block the visitors from the specific ipaddress 123.456.789.012 
deny from 123.456.789.  #blocks the visitors from all ip within the range 123.456.789.xxx (i.e. 123.456.789.000 – 123.456.789.255) 
deny from 123.456.   #blocks the visitors from all ip within the range 123.456.xxx.xxx 
deny from 123.    #blocks the visitors from all ip within the range 123.xxx.xxx.xxx 
allow from all    #allow from all other. 
0
<?php 

if (getenv(HTTP_X_FORWARDED_FOR)) { 
    $pipaddress = getenv(HTTP_X_FORWARDED_FOR); 
    $ipaddress = getenv(REMOTE_ADDR); 
echo "Your Proxy IPaddress is : ".$pipaddress. "(via $ipaddress)" ; 
} else { 
    $ipaddress = getenv(REMOTE_ADDR); 
    echo "Your IP address is : $ipaddress"; 
} 
?> 

此代码ü可以用它来得到访问者的IP地址......

要检测你需要一些免费的API区域.. Try this..

This Api can also be used..

第二个是很容易使用..

<A HREF="http://www.hostip.info"> 
<IMG SRC="http://api.hostip.info/flag.php?ip=12.215.42.19" ALT="IP Address Lookup"> 
</A>