cPanel: How to block visitor by country through GeoIP

To block a certain country IP range, you do not need to know which IP range it is and what you need is to use the GeoIP feature.

To install GeoIP, refer to the following URL,
http://www.mickgenie.com/cpanel-how-to-install-mod_geoip

Next, you will need to insert the following command to the .htaccess file,

RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$
RewriteRule ^(.*)$ http://www.google.com [L]

The command use to redirect China IP to google.com***

***This is an example only and it is not to abuse any user/visitor reside in China.

Redirect A Website with mod_rewrite

.htacess is very useful when you want to manage your website. It can be used to define the value that you want, block certain IPs, etc.

To redirect a website, you do not need to hard code from every single of your page, but you may use the .htaccess rewrite to get it done.

To redirect a domain name to www such as mickgenie.com to www.mickgenie.com

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mickgenie\.com$
RewriteRule ^(.*)$ http://www.mickgenie.com [R=301,L]

To redirect mickgenie.com and www.mickgenie.com to www.mickgenie.com

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mickgenie\.com$ [OR]
RewriteCond %{HTTP_HOST} ^mickgenie\.com$
RewriteRule ^(.*)$ http://www.mickgenie.com [R=301,L]