I want to block only 1 country from acsess to my server. How can i do it ? I am from this country and i need to have the option to acsess the server . Thanks in advance
I know this way of ip2nation , but I want to block 'X' country , I am Also from 'x' country , and i want to see the website, how can i do it ??
There is a PHP script inside www.sourceforge.net that redirects specific countries to any given page or URL outside your server. I don't remember the name but use "country redirection" as query to search and filter the results to programming language PHP It works, I had it installed on a website a couple of years back and doesn't require the huge country/IP database required by others.
huh... I told you to use an authentification system, if the visitor is from your country, you redirect him to the authentification page, if you want to visit your website then you will provide the password... Anyway, do you have a good PHP knowledge? Is you ISP giving you a static IP ?
or u can use a .htacces file an example is : <Limit GET HEAD POST> order deny,allow # Country: AFGHANISTAN # ISO Code: AF # Total Networks: 14 # Total Subnets: 65,792 allow from 58.147.128.0/19 allow from 117.55.192.0/20 allow from 117.104.224.0/21 allow from 119.59.80.0/21 allow from 121.58.160.0/21 allow from 121.100.48.0/21 allow from 121.127.32.0/19 allow from 125.213.192.0/19 allow from 202.56.176.0/20 allow from 202.86.16.0/20 allow from 203.174.27.0/24 allow from 203.215.32.0/20 allow from 210.80.0.0/19 allow from 210.80.32.0/19 # deny from all </Limit> Code (markup):
you can use, ip-to-country or maxmind products to block or redirect it. here is links: http://ip-to-country.webhosting.info/ http://www.maxmind.com/app/geolitecountry [code] you may see usage of databases at their site. Code (markup):
Use the database from http://www.ip2nation.com/, and then use this: if ($countryName == "[Your Country Name]" && $_SERVER['REMOTE_ADDR'] != "[Your IP Address]") { header ("Location: http://www.yoursite.com/banned.php"); } Code (markup):
GeoIP/mod_geoip makes it very easy to block access to a one or multiple countries. You can configure it so that access by you is allowed.
here is a code snippet using maxmind free geoip country lite version 1. you need to download 2 files. http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz http://www.maxmind.com/download/geoip/api/php/geoip.inc Code (markup): 2. unzip GeoIP.dat.gz 3. code require('geoip.inc'); $banned_country = ''; // your country code (look inside geoip.inc for the country code). $ip = $_SERVER['REMOTE_ADDR']; $gi = geoip_open('GeoIP.dat', GEOIP_STANDARD); $ip_country = geoip_country_code_by_addr($gi, $ip); geoip_close($gi); if ($ip_country == $banned_country) { header('Location: http://google.com'); // redirect to where you want. } PHP:
if you'd like to exclude your own ip from being banned, you can try using free service like no-ip.com or dyndns.com combining with their small windows program to automatically detect your current ip and update a hostname of your choice on their system. and here is the code to exclude your hostname. require('geoip.inc'); $banned_country = ''; // your country code (look inside geoip.inc for the country code). $exclude_hostname = ''; // your hostname which you register with no-ip.com or dyndns.com $ip = $_SERVER['REMOTE_ADDR']; $gi = geoip_open('GeoIP.dat', GEOIP_STANDARD); $ip_country = geoip_country_code_by_addr($gi, $ip); geoip_close($gi); $exclude_ip = gethostbyname($exclude_hostname); if ($ip != $exclude_ip) { if ($ip_country == $banned_country) { header('Location: http://google.com'); // redirect to where you want. } } PHP: