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
- Log into the cPanel.
- Click on the “File Manager” from the “File”.
- Click on “.htaccess” file and go for the “Edit” option.
- For blocking a Single User-agent, Insert this code –
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} UserAgentName [NC] RewriteRule .* - [F,L]
- 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