WordPress is an open source content management tool. It is written in PHP and MySQL. It is an easy platform to create beautiful sites. There may be various reason to block countries from your website. Sometimes you may face attacks from a specific country, get spam posts in your site or you just want to deny access to your site from certain countries. In this tutorial, you will learn different steps of blocking a specific country.
- A Domain Name
- Hosting service with cPanel access or FTP
First, we will learn how we can block a site using .htaccess file. Open the .htaccess file located in the public_html directory. You can access the file using File manager of cPanel or through FTP application.
Go to File manager from your cPanel. Go inside public_html directory where you will find the .htaccess
Go to this website where you can generate a list of IP addresses for a specific country.
Select the country and select format as .htaccess Deny and create ACL. It will generate a list of IP addresses for that country.
Copy the list of IP addresses and paste it inside the .htaccess file. Click on Save changes to make sure it is saved.
By following above mentioned steps, you can easily block your wordpress site in specific country.