How To Block Countries In WordPress

How To Block Countries In WordPress

[openingText]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.[/openingText]

Prerequisites

  • [tool]A Domain Name[/tool]
  • [tool]Hosting service with cPanel access or FTP[/tool]

Step 1:

First, we will learn how we can block a site using .htaccess file. [step]

[stepName]Open the .htaccess file located in the public_html directory. [/stepName]
You can access the file using File manager of cPanel or through FTP application.

[stepImage]How To Block Countries In WordPress[/stepImage]

[/step]

Step 2:

Go to File manager from your cPanel. [step]

[stepName]Go inside public_html directory where you will find the .htaccess[/stepName]

[stepImage]How To Block Countries In WordPress[/stepImage]

[/step]

Step 3:

[stepName]Go to this website where you can generate a list of IP addresses for a specific country.[/stepName]
[step]

Select the country and select format as .htaccess Deny and create ACL. It will generate a list of IP addresses for that country.


[stepImage]How To Block Countries In WordPress[/stepImage]

[/step]

Step 4:

[stepName]Copy the list of IP addresses and paste it inside the .htaccess file.[/stepName]
[step]Click on Save changes to make sure it is saved.[/step]

Conclusion:

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

Check out the top 3 WordPress hosting services:

Hosting.com
NZ$5.10 /mo
Starting price
Visit Hosting.com
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
NZ$1.71 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.9
  • Support
    4.9
  • Features
    4.8
  • Reliability
    4.8
  • Pricing
    4.6
Hostinger
NZ$2.71 /mo
Starting price
Visit Hostinger
Rating based on expert review
  • User Friendly
    4.9
  • Support
    4.9
  • Features
    4.8
  • Reliability
    4.7
  • Pricing
    4.5

How to change the WordPress Admin login URL

Many wordpress sites are hacked for not being more secured. In this guide we wil
less than a minute
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
less than a minute
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
less than a minute
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
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert
Click to go to the top of the page
Go To Top
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.