Web Hosting Knowledge Base / Website Hosting: How-To

GeoLocation Enabled: Allow/Deny access to your website by country

We’re happy to announce a new feature for our hosting customers — GeoLocation support is now available!

What is GeoLocation?

GeoLocation lets your website detect where visitors are coming from — specifically, their country — based on their IP address.

Where is it available?

This feature is currently available only on LiteSpeed-based servers.

What can you do with GeoLocation?

With GeoLocation and .htaccess rules, you can: Limit access to your entire website or specific folders by country, protect your site from unwanted or suspicious traffic. It eliminates the need to use premium (paid) WordPress security plugins like the premium version of Wordfence. GeoLocation gives you more control over who can access your site, helping keep it secure — all at no extra cost!

Examples:

1. Add this code in the top of .htaccess file to allow the visitors from US and Canda only to visit your website.

<IfModule mod_geoip.c> RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(US|CA)$ RewriteRule .* - [R=403,L] </IfModule>

2. Add this code in the top of .htaccess file to allow visitors from all countries except US and Canada

<IfModule mod_geoip.c> RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(US|CA)$ RewriteRule .* - [R=403,L] </IfModule>

3. Redirect based on Country

<IfModule mod_geoip.c> # Redirect one country RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$ RewriteRule ^(.*)$ http://www.canada.com$1 [R,L] # Redirect multiple countries to a single page RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$ RewriteRule ^(.*)$ http://www.northamerica.com$1 [R,L]
</IfModule>

Last update: Oct 23, 2025 18:27