Countries can be blocked from visiting site by adding a deny rule to the site's .htaccess. This guide will show how to enter code to block specific countries. You can do so using the text editor in cPanel's File Manager.
Related Articles
Find the Document Root of a Domain
Edit File with File Manager
Block Specific Country
TIP: More information on Restricting access with .htaccess and the IP Blocker can be found in Restrict access with .htaccess and the IP Deny Manager.
- Get the IP list of the country to be blocked
- Visit https://www.ip2location.com/free/visitor-blocker
- Navigate towards the bottom of the page to the Download List section
- Select the Following:
- Country
NOTE: Select the country you intend on blacklisting, e.g., China. - IP Version: IPV4
- Change Output Format to Apache 2.0 - 2.3 .htaccess Deny
- Country
- Click Download
- Window appears to Save or Open File
- Open with Notepad
- Copy entire contents of the file
- Select the Following:
- Log into the appropriate cPanel
- Navigate to File Manager
- Navigate to document root for the domain
- Locate the .htaccess file and edit the file
NOTE: The .htaccess file is hidden. To see it, the Show Hidden Files (dotfiles) setting must be checked in File Manager's Preferences menu. Access Preferences from the Settings button at the top right of File Manager window. - Paste the contents of the Blocked Country File from Notepad to the top of the .htaccess file
- Click Save Changes
Comments
0 comments
Article is closed for comments.