1. What do you want to do with the selected countries?
⚠️ Note: you have selected the United States (US) to block.
This can negatively impact your SEO — Googlebot and other crawlers/tools often operate from
US IP addresses, as do many international visitors/analytics services. Consider this carefully
before going live.
2. Which server does your site run on?
Not sure? Ask your hosting provider, or check cPanel under "Server Information" — it often lists
"Apache" or "LiteSpeed Web Server".
Apache uses SetEnvIf combined with Deny from env (via mod_access_compat), so existing vhost-level rules such as basic authentication stay intact.LiteSpeed uses its own mod_rewrite-based method
(RewriteCond/RewriteRule), since LiteSpeed's SetEnvIf/Require support
for GeoIP doesn't work reliably. On LiteSpeed, GeoIP must also first be enabled at server level — via the
WebAdmin Console or cPanel — this cannot be done through the .htaccess file itself. Check with your hosting provider before
using the code below.
3. Select countries 0 selected
4. Your .htaccess code
Copied!
Note: this code only works if GeoIP detection is active on your server (on Apache via mod_geoip2
or mod_maxminddb; on LiteSpeed via the built-in GeoLocation module, enabled in the WebAdmin Console or cPanel),
with a valid GeoIP/GeoLite2 database. Check with your hosting provider, or test on a staging environment first before going live.
Place the code at the top of your .htaccess file, before any other Rewrite rules.