How to block unwanted bots with .htaccess file using Cpanel?

Short tutorial on How to block unwanted bots with .htaccess file using Cpanel?

Block Unwanted Spam Bots With .Htaccess

In this article well discuss how you can block unwanted bots from accessing your website via .htaccess file using Cpanel. Follow the steps below to block unwanted bots from being able to access your website.
Step 1: Login to your Cpanel → FilemanagerCpanel Filemanager
Step 2: Select Public_html

Filemanager Publichtml
Step 3: Goto Settings
Goto Settings
Step 4: Select the Document Root for: option, and choose your domain from the drop-down. Ensure that Show Hidden Files is selected. Then Click "Save".
Settings Document Root
Step 5: Right-click on the .htaccess file and select Edit.
Htaccess Edit
Step 6: Use the RewriteRule given below to block one particular User-Agent.
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} Baiduspider [NC]
RewriteRule .* - [F,L]

or BrowserMatchNoCase "Baiduspider" bots
Order Allow,Deny
Allow from ALL
Deny from env=bots

Step 7: Use the RewriteRule given below to block multiple User-Agents.
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|HTTrack|Yandex).*$ [NC]
RewriteRule .* - [F,L]

or BrowserMatchNoCase like this:
BrowserMatchNoCase "Baiduspider" bots
BrowserMatchNoCase "HTTrack" bots
BrowserMatchNoCase "Yandex" bots
Order Allow,Deny
Allow from ALL
Deny from env=bots

Step 8:
Save and upload the same. You are done.


Related Topics