This article explains how to block bots from Apache with WHM/cPanel.
Bot crawlers are important algorithms that index your website. Though some bots are beneficial, others can lead to issues such as increased server load or network instability. In such scenarios, you can effectively block these challenging bots using Apache with a WHM/cPanel server.
Follow these steps to block bots from Apache:
- Log in to WHM.
- Navigate to the “Service Configuration” option from the menu.
- Click on “Apache Configuration”. This will display the configuration options for the Apache server.
- Select “Include Editor”.
Here, you can apply configurations to your Apache server globally.
- In the “Pre Main Include” section, choose “All Versions” from the drop-down list under “I wish to edit the pre-main configuration include file for:”.
A text box will appear in the “Pre-Main Include” section, where you can enter your configurations.
- Paste or type the following code into the editor and then click the Update button<Directory “/example”>
SetEnvIfNoCase User-Agent “MJ12bot” bad_bots
SetEnvIfNoCase User-Agent “AhrefsBot” bad_bots
SetEnvIfNoCase User-Agent “SemrushBot” bad_bots
SetEnvIfNoCase User-Agent “Baiduspider” bad_bots
<RequireAll>
Require all granted
Require not env bad_bots
</RequireAll>
</Directory>
Note: Replace /example in the first line of the Directory section with the actual directory path where your website is located. For cPanel servers, the default path is /home. You can also block additional bad bots by adding them to the code using the same syntax.
In this manner, you can block bots from Apache with WHM/cPanel.
Are you Looking for an alternative method to block bots? then you can block the bots with .htaccess file in cPanel.
We hope you liked our article. However, if you encounter any issues, reach out to our support team.