Block bad bots via .htaccess

Do you see a lot of traffic to your site from bad bots? If you have a WordPress site, maybe the first reaction is to search for a WordPress plugin that will block such visits. But instead of using a free/paid WordPress plugin, you can also modify the .htaccess file from the root of your site. The location of the file is most of the time /home/username/public_html/.htaccess.

You can apply these rules to any website. WordPress or not.

Just edit the file and add these lines:

#Rules to block bad bods from accessing web pages on your site. 
#Remove or add more rules as per your needs.
BrowserMatchNoCase "Baiduspider" bots
BrowserMatchNoCase "SemrushBot" bots
BrowserMatchNoCase "Yandex" bots
BrowserMatchNoCase "BLEXBot" bots
BrowserMatchNoCase "AhrefsBot" bots
BrowserMatchNoCase "DotBot" bots
BrowserMatchNoCase "Exabot" bots
BrowserMatchNoCase "SeznamBot" bots
BrowserMatchNoCase "aiHitBot" bots
BrowserMatchNoCase "spbot" bots
BrowserMatchNoCase "MJ12bot" bots
BrowserMatchNoCase "oBot" bots
BrowserMatchNoCase "DeuSu" bots
BrowserMatchNoCase "ia_archiver" bots
BrowserMatchNoCase "MetaURI" bots
BrowserMatchNoCase "FlipboardProxy" bots

Order Allow,Deny
Allow from ALL
Deny from env=bots

These bots will now get a 403 HTTP Error when trying to access your pages.

Double-check the bots you want to block! Not all bots are bad.

Using the .hatccess file, you can also block bad IPs. If you know malicious IPs, add them like:

#Deny malicious bots/visitors by IP addresses.
deny from 118.244.181.33
deny from 82.102.230.83

How to edit the .hatccess file in cPanel:

1. Connect to your account via an FTP client like FileZilla FTP Client and edit the file.
2. Use the cPanel File Manager. Login to your cPanel account and go to File Manager

cpanel file manager icon
cPanel File Manager icon

To buy a web hosting plan check our dedicated page for Web Apps Hosting.

This Post Has One Comment

Leave a Reply