How To Block Countries In WordPress

How To Block Countries In WordPress

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.

Prerequisites

  • A Domain Name
  • Hosting service with cPanel access or FTP

Step 1:

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.

How To Block Countries In WordPress

Step 2:

Go to File manager from your cPanel.

Go inside public_html directory where you will find the .htaccess

How To Block Countries In WordPress

Step 3:

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.


How To Block Countries In WordPress

Step 4:

Copy the list of IP addresses and paste it inside the .htaccess file.

Click on Save changes to make sure it is saved.

Conclusion:

By following above mentioned steps, you can easily block your wordpress site in specific country.

Check out the top 3 WordPress hosting services:

A2 Hosting
$2.99 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0

How to change the WordPress Admin login URL

Many wordpress sites are hacked for not being more secured. In this guide we wil
1 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Restrict Bots From Accessing Your WordPress Site

Security has been a major concern these days. This guide will walk though the pr
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Logout All Users In WordPress At Once

What will you do if your WordPress site has been hacked or want all the users to
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to Install Google re-CAPTCHA on Your Wordpress Site

In this guide, we will show you how to install re-CAPTCHA on your WordPress site
3 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top