Robot Portal

Easily manage all aspects of your account | Knowledgebase |

Usage: mod_geoip

We have seen loads of our clients use .htaccess to block different type of country (Using Ip ranges). There are several reasons for doing it. Most of the cases, Webmasters block country traffic for abusing Bandwidth, Protecting Google Adsense Smart Pricing etc. Although, .htaccess blocking works, but it creates extra loads on the server. As we are not intended to block or suspend anyone's account for such thing, thats why we have implemented mod_geoip on the server and suggest our clients to block traffic (If required) using mod_geoip instead of IP range blocking using .htaccess

mod_geoip needs to be implemented using .htaccess, it is also configurable using PHP. Here we will describe some examples to block countrywise traffic using mod_geoip and .htaccess (Without IP range)

To block traffic other than US, UK and Canada use the following code:


RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !(US|GB|CA)$
RewriteRule ^(.*)$ block.php [NC,L]

This code is negating for the traffic of US, GB and CA and redirecting them to block.php, you can change it to different site like, to redirect traffic to google.com just replace block.php to http://www.google.com

To block certain traffic you can use a code for example:


RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} (CN|IR)$
RewriteRule ^(.*)$ block.php [NC,L]

This code will block the traffic from China and Iran, then redirect them to block.php. block.php is also replacable with a website address. But it must be included with "http://"

Country code is Important here, as country code needs to be used to block the traffic from countries. You can find the country code located http://www.maxmind.com/app/iso3166

  • 50 Users Found This Useful

Was this answer helpful?

Related Articles

Binary Location of FFMPEG!

[Applicable for all of our servers]If you are trying to use FFMPEG, then you would be looking for...

Binary Location of Required Modules to play embedded Video!

[Applicable for the server name All CentrioHost's Servers] Mplayer /usr/local/bin/mplayer...

ImageMagick Location

Imagemagick binary/convert is located under /usr/binConvert file: /usr/bin/convert

PHPShield Error

Please take a look at the following url: http://phpmotion.com/forum/index.php?topic=74.0 If you...

Over 20000 Satisfied Customers!

  • web hosting reviewer
    Valerie Quinn
    CTO, Acteon Group

    Centriohost staff were fantastic, I had a concern with a domain and they got back to me very quickly and they helped me to resolve the issue! ~ . . . Read more

  • Joomla hosting reviewer
    Collin Bryan
    Photographer, Allister Freeman

    I'm using centrio for my portfolio since 2006. The transition was seamless, the support was immediate, and everything works perfectly. ~ . . . Read more

  • dedicated server reviewer
    Harry Collett
    Actor, A&J Artists

    Very easy to understand & use even though I am not very technologically minded. No complications whatsoever & I wouldn't hesitate to recommend it to all. ~ . . . Read more

  • vps web hosting reviewer
    Porfirio Santos
    Technician, Diageo PLC

    Centrio support team have been amazingly responsive and helpful to any of my queries, thank you so much to the Centriohost have been amazingly responsive and helpful to any of my queries ๐Ÿ‘๐Ÿ‘๐Ÿ‘ ~ . . . Read more

  • wordpress hosting plans reviewer
    Catherine Auer
    Doctor, SmartClinics

    Anytime I've had a problem I can't solve, I've found Centriohost to be diligent and persistent. They simply won't let an issue go until the client is happy. ~ . . . Read more

  • reseller hosting reviewer
    Effectivo Social
    Freelancer, Fiverr

    Recommend their shared hosting for all my SME web design clients. Their cloud or VME offerings are too great to deal with. Pricing is perfect and suitable for all users (อ โ‰– อœส–อ โ‰–) ๐Ÿ‘Œ ~ . . . Read more