I'm in process to block a particular geolocation from accessing my site. But i am not sure if this is going to raise any flags on my website. Basically i'm getting lots of spam from particular state and there are some webmaster copying my content without any attribution or backlink. I feel that is enough and i wish to save my bandwidth on that state or geolocation.

So my question is how to block particular geolocation ? Do you have any suggestions for php scripts that help block particular geolocation ? and another question: if there are any SEO disadvantages ?

  • When you say "state", do you mean one of the United States, or a state in another country, or a whole country in general? Nov 18, 2011 at 16:38
  • Not united states but another state in China. If possible i don't mind blocking entire country.
    – Mahesh
    Nov 20, 2011 at 19:43

1 Answer 1


There are many geolocation scripts and services out there, just search. Here's a PHP one for example. Usually you can get quite fine-grained location data.

As for SEO, it could harm your SEO if you block a search engine from accessing your website. Google has a limited presence in China, and Googlebot mostly (if not exclusively) operated from the USA. However other search engines like Baidu are popular.

You could first check whether the visitor is a search engine - e.g. check for "Googlebot" of "Baidu" in the user agent string. If they're not a search engine, run your geolocation check and block them if they match your target area. (Note, if they are specifically targeting your site there's a possibility they may get wise to this tactic and spoof the user agent.)

  • I checked the serverlogs and this seems to be user posting comments. Definitely bot posting spam comments. I do have baidu in search engine list but they hardly pass traffic to my site.
    – Mahesh
    Nov 21, 2011 at 14:45
  • Do you think allowing the access only to Google could raise a cloaking alarm with them? Users can not see the content, but Google can. Feb 6, 2015 at 14:16
  • @Mahesh Blocking is only a band aid and not resolving the real issue. Your issue is your comment footprint, remove the footprint and remove 99% of spam. Feb 6, 2015 at 14:26
  • I would not block a geographic region without also blocking Googlebot when it crawls from that region. Google allows you to make choices for your website based on geo IP address, but treating Googlebot differently in those decisions is cloaking. Feb 6, 2015 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.