| 8:51 am on May 19, 2012 (gmt 0)|
you can block IP addresses but not geographies.
depending on which country it can be simple or nearly impossible to define the IP range(s) associated with that country.
if your visitor is determined enough to access the site through a proxy on an unblocked IP address you're out of luck.
| 9:12 am on May 19, 2012 (gmt 0)|
Technically it is possible, but it's not as easy as one might wish. IP address ranges are not assigned by country, so any large range probably has smaller sub-ranges within it from a variety of different countries. That is, if you see an IP address from your banned country, you can't block all IPs starting with similar digits, because you'll probably be banning visitors from other countries, too.
In your web search for solutions, the keyword you need is "GeoIP" or maybe "geolocation". I believe that will lead you to databases and subscription lookup services that can translate an individual IP to its country of origin.
To implement on your server, you'll need to look up the IP of each incoming request to determine its country of origin. If it is the banned country, return a 403 response.
I believe there might be an Apache module that can carry out these lookups. Or if your code is all PHP, you can probably do it in PHP. However you do it, it probably adds significant overhead to the handling of each request.
An alternative to a subscription lookup service would be to manually build your own database of as many IP address ranges as you can find from the banned country (not an easy project, I suspect), and use your own code to consult that database for each request.
| 10:00 am on May 19, 2012 (gmt 0)|
if it's an apache server you can use a couple of methods of Access Control:
| 12:47 am on May 20, 2012 (gmt 0)|
|IP address ranges are not assigned by country, so any large range probably has smaller sub-ranges within it from a variety of different countries. That is, if you see an IP address from your banned country, you can't block all IPs starting with similar digits, because you'll probably be banning visitors from other countries, too. |
And how! Currently about 2/3 of the "Deny from..." section of my htaccess is devoted to The Unwanted Country-- and that's nowhere near a complete list. To keep things sane I cut off at /16 (that is, aa.bb) unless I meet an individual nasty in a smaller range. If I included everything, the list would be more than twice as long.
You could throw in a language block. But unless you're locking out a major European country-- somehow I doubt this is what you want to do-- the language probably won't even show up in the UA.
| 6:14 am on May 20, 2012 (gmt 0)|
Blocking by language detected in the user-agent may be of use here.
| 11:33 am on May 23, 2012 (gmt 0)|
Thanks you all for taking time answer my query.
I have used Block by IP method :)
| 5:16 pm on Jun 14, 2012 (gmt 0)|
on robots file?
| 8:50 pm on Jun 14, 2012 (gmt 0)|
the only thing you can block in robots.txt is crawling by well-behaved bots.
| 9:29 pm on Jun 14, 2012 (gmt 0)|
If you are on a dedicated Linux server then it may be possible to block at the IP level using iptables or similar firewall software. This essentially prevents any traffic from the problem IPs ever getting to Apache. However with some countries you may be blocking thousands of IP ranges and you are not going to get a 100% solution due to the web proxy issue.