Block bad bots on cPanel globally with Apache

A lot of traffic from bad bots, crawling your sites can cause problems such as high server load and unstable server. You should use mod_security on cPanel servers that should do the job, but if you want to block specific bots globally, on apache level, then bellow solution is for you. This syntax is for Apache version 2.4.

On cPanel servers you can’t just edit httpd.conf file, it will be rewrited. You can edit it through whm easily. Just login on your cpanel -> Apache Configuration -> Include Editor -> go to “Pre Main Include” -> select your apache version (or all versions) -> then insert code bellow and click Update and then restart apache.

In Directory section, you should specify right path to location where websites are. On cpanel servers this is /home by default.

Here is my example:

<Directory "/home">
   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>

Got Something To Say:

Your email address will not be published. Required fields are marked *

*

I accept the Privacy Policy

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 geegkytuts.net
Hosted by SIEL


About author