hi, i recently opened a proxy website and a few people on this site told me that i should use .htaccess to block countries like iran since they use most of the bandwith. the only problem is that i have no clue on how .htaccess works and i need some guidence on setting it up
To block a country you need the countries ip adresses. You can get them for example here: http://ip-to-country.webhosting.info/node/view/6 Then you need to put this ip's in the htaccess file like this: order allow,deny deny from 127.0.0.1 deny from 127.0.0.2 deny from 127.0.0.3 allow from all Code (markup): But its a lot of work, and the IP's are changing constantly..
is that the only thing i need in the htaccess file? or are there more things that go into an htaccess file?
Yes that is, but do no use 127.0.0.1, etc. that are the localhost ranges. Use the IPs belonging to the countries that you want to block following the above link to find them out.
Hello, The most efficient and easy way is to block, or allow users from a certain country to visit your website is with the help of a so called .htaccess file on your server. In this .htaccess file you write which ip addresses should not have access and which ip addresses should have access. The website located on blockacountry.com gives a service where you can easily click on the countries you wish to block. Following blockacountry.com generates you a .htaccess document which you can upload to your server and there you go. As easy as 1,2,3. Wildcard
Well is it ip range? which are the dangerous places other than china i dont support blocking whole east/asia
You can get complete ip ranges address for countries on: http://www.ipaddresslocation.org/ip_ranges/get_ranges.php Then use what evera already told you.
I'm not sure, but perhaps the answer to the section below may help. A friend is experiencing massive problems on bandwidth and needs to use his htaccess to block certain countries, but it doesn't seem to work, any ideas please ? How could it be adjusted to work ? <limit GET> deny from BR, RU, CN, RO, SN, SK </limit> Any help very much appreciated. Kezi
That's a massive shame, there would be about 80 countries in total = a lot of ip ranges = a big load every time a page is parsed. Also a lot of typing ;-( Kezi
Or perhaps PHP ? [?php $country = geoip_country_code_by_name($_SERVER["REMOTE_ADDR"]); if (!(($country == "USA") or ($country == "CA") or ($country == "GB") or ($country == "AU"))) { die("Service Unavailable!"); } ? Obviously would need customizing to adapt, but has it got any potential ? Would be a lot easier than inputting 100's of numbers.
How do the others here block multiple countries from viewing their websites please ? If you block say 15-20 countries, you're looking at a few hundred ip ranges ! Big hit on loading each page !! Any help very much appreciated. Kezi
Just FYI - I was looking up this thread for info on htaccess wildcard IP blocks - and I'm an expat working in Macao SAR. So please don't block us - some of us are the good guys.
Found this post in a search result... is there any new ways to accomplish this? ( i noticed the post is 2 years old.)