GeoIP block country

The free edition of the GeoIP database is not as accurate as the subscription based database.

Test this by working inside a non important testing directory with a simple testing file such as:

Create a new .htaccess file with the following contents:

Deny from env=BlockCountry

This will block GB from your testing directory. Note, this document is only intended to illustrate the possibilities of the use of GeoIP for a basic how to.

Or If you want to redirect based on the country using mod_rewrite in combination with mod_geoip, your .htaccess file could look like this:

RewriteEngine on
RewriteRule ^(.*)$$1 [L]

You do not need to enter the path in your .thaccess file:
GeoIPDBFile /path/etc/
Doing so will result in a 500 server error!

Please see the following 3rd party site, the makers of GeoIP for further details:

Posted in .

Leave a Reply