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 humans.
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 types of known are listed on 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]
Step 4:
You can also restrict access if you know the IP address of the bot. You can list the IP addresses in the .htaccess file
#Restrict IP of botsDeny from 123.123.45.184Deny 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 sites safe from malicious bots.