How To Restrict Bots From Accessing Your WordPress Site

How To Restrict Bots From Accessing Your WordPress Site

A bot is an application that is automated and runs script over the internet. They can perform tasks faster and can do repetitive tasks at a much higher rate than human.

Bots can make your life easier and sometimes it can be a nuisance. Bots can use your resources, breach your security and create other problems. In WordPress, bots can be used to breach the security of databases, login portal, hosts, etc.

In this guide, you will learn how to restrict both from accessing your WordPress site by making some changes in the .htaccess file & by using some WordPress plugins.

Prerequisites

  • A Domain name (e.g., example.com)
  • cPanel access
  • Text editor
  • FTP application

Step 1:

First, we will learn how to restrict bot from accessing the site by .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.

Step 2:

Click File manager from your cPanel. Go inside public_html directory where you will find the .htaccess

Step 3:

Now, we need to restrict bots by adding some codes to the .htaccess file. Different type of known are listed in this site. Add the following lines of code to your .htaccess file to restrict bots from your site

#Block Bad User Agents
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^SpiderMan[OR]
RewriteCond %{HTTP_USER_AGENT} ^voyager[OR]
RewriteCond %{HTTP_USER_AGENT} ^WaveFire
RewriteRule .* - [F,L]

In the above code, SpiderMan, voyager and Wavefire are the bots. These can be replaced by the bots you want to block. The last line of code requests the server to give a 403 error to the bots in the code.

Step 4:

You can also restrict the access if you know the ip address of the bot. You can list the ip addresses in the .htaccess file

#Restrict IP of bots
Deny from 123.123.45.184
Deny from 123.123.99.952

#Restrict IP range of bots
Deny from 123.123.123.0/24

You can add the IP address or the range of IP address of the bot that you want to block.

Step 5:

Also, you can install various plugins available in WordPress to restrict bots to access

Your wordpress site. Some of the know plugins are iThemes Security, All In one WP security & firewall, StopBadBots, etc.

Conclusion

By following the steps mentioned, you can make your site safe from malicious bots to access your site.

 

Check out these top 3 WordPress hosting services:

A2 Hosting
£2.35 /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
£0.79 /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
£1.96 /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 Change the Database Port for WordPress

This guide will help you on how to change the database port of your Wordpress we
1 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

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