How to block bots from Apache with WHM/cPanel

July 15, 2024 / cPanel & WHM

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:

  1. Log in to WHM.
  2. Navigate to the “Service Configuration” option from the menu.
  3. Click on “Apache Configuration”. This will display the configuration options for the Apache server.
    Apache Configuration
  4. Select “Include Editor”.
    Here, you can apply configurations to your Apache server globally.
    Include Editor
  5. 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.
    Pre Main Include
  6. 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>

    block bots from apache
    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.

Spread the love