2012-01-05 107 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>