On Blueboard hosting, you can use the .htaccess file to restrict
access to your website by the visitor’s country or block selected bots.
The server determines the country based on the IP address using the MaxMind
database. The detected country code is available in the
MM_COUNTRY_CODE variable. Geolocation is not 100% accurate and,
when using a VPN, it may correspond to the country of the exit server.
Before you start
Back up your original .htaccess file. Add the rules
before the existing URL rewrite rules, for example before the
# BEGIN WordPress block. Keep your site’s original rules.
Country-based restrictions also apply to search engines, monitoring, and external services, such as payment notifications. Before enabling it, consider where your site must be accessible from.
Allow access only from selected countries
The following example allows access only from the Czech Republic and
Slovakia. For all other requests, the server returns a
403 Forbidden error.
RewriteEngine On
# Allow only the Czech Republic and Slovakia
RewriteCond %{ENV:MM_COUNTRY_CODE} !^(CZ|SK)$
RewriteRule ^ - [F]
Edit the list of countries to suit your needs. Separate codes with the
| character, for example:
RewriteCond %{ENV:MM_COUNTRY_CODE} !^(CZ|SK|DE|PL|AT)$
Common country codes:
- Czech Republic:
CZ - Slovakia:
SK - Germany:
DE - Poland:
PL - Austria:
AT - United Kingdom:
GB - United States:
US
This variant will also block requests where the country cannot be determined.
Blocking selected bots
Bots can be filtered by name in the User-Agent HTTP header. The
following example blocks requests containing meta-externalagent,
Bytespider, or ClaudeBot regardless of
letter case.
RewriteEngine On
# Block selected bots by User-Agent
RewriteCond %{HTTP_USER_AGENT} (meta-externalagent|Bytespider|claudebot) [NC]
RewriteRule ^ - [F]
This filter is not a reliable verification of a bot’s identity. A client
can change the User-Agent header arbitrarily and bypass
the block.
Combining both restrictions
If you want to block selected bots and at the same time allow access only from the Czech Republic and Slovakia, use:
RewriteEngine On
# Block selected bots from all countries
RewriteCond %{HTTP_USER_AGENT} (meta-externalagent|Bytespider|claudebot) [NC]
RewriteRule ^ - [F]
# Allow other requests only from the Czech Republic and Slovakia
RewriteCond %{ENV:MM_COUNTRY_CODE} !^(CZ|SK)$
RewriteRule ^ - [F]
Search engines and Googlebot
Geographic restrictions can also block Googlebot and other search engines. Long-term unavailability of content may affect its indexing.
We do not recommend adding an exception based only on the Googlebot name in the User-Agent header. Such an exception could be exploited by anyone pretending to be Googlebot.
The real origin of requests can be verified using IP ranges published by Google or using DNS according to the official Google procedure.
If availability for search engines and external services is important for your site, contact our support before implementing geographic restrictions.
Check after editing
After saving the file, verify the homepage as well as internal URLs on the site. Also check features that depend on external services.
If the site starts returning a 500 error, restore the original
.htaccess and check the syntax of the inserted rules. If it returns
403, verify the list of allowed countries and any blocking by
User-Agent.