How to Block Country Traffic in cPanel?
In order to prevent disputes or issues, you must block some people from seeing your website. Regular cPanel users can modify the htaccess file to prevent a country’s web traffic from reaching their server.
To Block Country Traffic
1. Log in to your cPanel account.
2. Edit the .htaccess file via the File Manager tool.
3. Enter this line at the end of the file:
<IfModule mod_geoip.c> RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$ RewriteRule ^(.*)$ – [F,L] </IfModule>
The given line has used the US, which is the country code for the United States of America. It will block all the web traffic from the country if you enter its country code here.
You can refer to this link ISO 3166-1 alpha-2 to find the country codes you are looking for.
4. Click on Save Changes and Close.

With it, the country traffic you choose to block will be screened by cPanel. It means the server will reject any access request from the country you blocked and return a 403 forbidden error for the users.