Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
When you say "state", do you mean one of the United States, or a state in another country, or a whole country in general? – DisgruntledGoat Nov 18 '11 at 16:38
Not united states but another state in China. If possible i don't mind blocking entire country. – Mahesh Nov 20 '11 at 19:43
up vote 1 down vote accepted

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.)

share|improve this answer
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 '11 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. – Bojan Miljevic Feb 6 '15 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. – Simon Hayter Feb 6 '15 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. – Stephen Ostermiller Feb 6 '15 at 15:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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