How to Block Bots with .htaccess file via cPanel

December 28, 2023 / cPanel & WHM

In this article, we will explain how to block bots with the help of .htaccess file from cPanel.

The .htaccess file is a basic text file placed in your website’s main directory. It helps search engine bots crawl and index your site, controlling their access to specific files. Proper configuration is crucial, and you can use this file to stop bots from indexing your website on search engines.

Follow these steps to block bots with the help of .htaccess file

  1. Log into the cPanel.
    cPanel Account
  2. Click on the “File Manager” from the “File”.
    File Manager
  3. Click on “.htaccess” file and go for the “Edit” option.
    edit .HTACCESS to block bots
  4. For blocking a Single User-agent, Insert this code –
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} UserAgentName [NC]
    RewriteRule .* - [F,L]
    
  5. For blocking multiple User-agents, you can insert this code in your .htaccess file.
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|HTTrack|Yandex).*$ [NC]
    RewriteRule .* - [F,L]

In this way, you can block bots with the help .htaccess file using cPanel. For more information on cPanel, visit our knowledge base section.

Also Read : How to create .htaccess file

Dominos Search