To redirect users based on country, IP range, ISP, city and many other options, I elected to use MaxMind GeoIP databases. There are many options to use the MaxMind GeoIP databases with your website. The two main ones are PHP or .htaccess/apache methods. This tutorial uses the Apache (mod_maxminddb) MaxMind APIs on a VestaCP based server to affect visitors. Using the .htaccess method of blocking/redirecting is orders of magnitude less resource intensive than PHP methods. First, either use the <a href="http://dev.maxmind.com/geoip/geoip2/geolite2/">free databases</a> in <strong>binary & gzipped format</strong> or purchase a license (we purchased the ISP license) and download the <strong>binary & gzipped format</strong>. SSH into your server (will need your own server for the .htaccess method) and then install the following tools to compile the API as described below: <code>yum install automake autoconf libtool -y</code> Install some more tools <code>yum install gcc-c++ httpd-devel wget -y</code> Next, you'll need libmaxminddb: <code>yum update -y yum install git -y git clone --recursive https://github.com/maxmind/libmaxminddb cd libmaxminddb libtoolize ./bootstrap ./configure make make check make install sh -c "echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf" ldconfig /bin/systemctl restart httpd.service</code> When that's finished, you will want to install <strong>MaxMind DB Apache Module</strong> which has <a href="http://maxmind.github.io/mod_maxminddb/">instructions here</a> but I will illustrate this below for CentOS 7 users and VestaCP users. Now, navigate to home directory and install mod_maxminddb <code>cd ~/ wget https://github.com/maxmind/mod_maxminddb/releases/download/1.0.1/mod_maxminddb-1.0.1.tar.gz tar -xzvf mod_maxminddb-1.0.1.tar.gz cd mod_maxminddb*</code> We will now install the apache module run the following: <code>./configure</code> You may get a load module error during make install, so run the following (on VestaCP only) to load a dummy module into the apache/nginx conf, and then run make install again <code>echo "#LoadModule foo_module /usr/lib/apache2/modules/foo.so" >> /etc/httpd/conf/httpd.conf</code> <code>make install</code> Restart web server <code>/bin/systemctl restart httpd.service</code> Great, now you use MaxMind GeoIP! We will be using Apache (mod_maxminddb) MaxMind APIs, documentation <a href="http://maxmind.github.io/mod_maxminddb/" target="_blank" rel="noopener noreferrer">can be found here</a>. <code>mkdir /opt/geoip cd /opt/geoip</code> Download the lite databases <code>wget --content-disposition "http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz"</code> <code>gunzip GeoLite*</code> Type ls and note down the .mmdb file name, ours is: <code>/opt/geoip/GeoLite2-Country.mmdb</code> For the ISP module, go to your maxmind downloads are and copy the URL for the GeoIP2 Binary GZIP file. <code>wget --content-disposition "url to download your gzip'ed database" tar -xzvf GeoIP2*.tar.gz cd GeoIP2* mv *mmdb .. cd .. ls</code> Note down the .mmdb file name, ours is: <code>/opt/geoip/GeoIP2-ISP.mmdb</code> Check mod_maxminddb is at the bottom of our httpd.conf file: <code>cat /etc/httpd/conf/httpd.conf</code> You should see: <code>LoadModule maxminddb_module /usr/lib64/httpd/modules/mod_maxminddb.so</code> Now, navigate to your web folder, on VestaCP it is /home/admin/web/*/public_html/ <code>cd /home/admin/web/*/public_html/</code> Edit .htaccess <code>vi .htaccess</code> Use examples as provided in the <a href="http://maxmind.github.io/mod_maxminddb/" target="_blank" rel="noopener noreferrer">documentation page</a>. <h2>Part 2: Redirecting visitors based on ISP with the GeoIP2-ISP database</h2> Here is an example of country based .htaccess that will ALLOW specific countries and block the rest. <code><IfModule maxminddb_module> ErrorDocument 403 "403" Order Deny,Allow Deny From All MaxMindDBEnable On MaxMindDBFile DB /opt/geoip/GeoLite2-Country.mmdb MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code SetEnvIf MM_COUNTRY_CODE ^(US|CA|AU|UK) AllowCountry Allow from env=AllowCountry </IfModule> </code> See more: <a href="https://sick.codes/bulk-check-ip-list-csv-txt-data-with-maxmind-mmdb-mmdblookup/">Bulk check IP list (CSV, txt) data with MaxMind mmdb (mmdblookup)</a>