{"id":2336,"date":"2025-07-18T10:40:02","date_gmt":"2025-07-18T10:40:02","guid":{"rendered":"https:\/\/hostrago.com\/knowledge-base\/?p=2336"},"modified":"2025-07-18T10:40:04","modified_gmt":"2025-07-18T10:40:04","slug":"block-bots-apache-whm-cpanel","status":"publish","type":"post","link":"https:\/\/hostrago.com\/knowledge-base\/block-bots-apache-whm-cpanel\/","title":{"rendered":"How to Block Bots from Apache with WHM\/cPanel?"},"content":{"rendered":"\n<p>By using <strong>WHM\/<a href=\"http:\/\/cpanel.net\" target=\"_blank\" rel=\"noopener\">cPanel<\/a><\/strong>, server administrators can easily implement configurations on the Apache web server to block malicious bots and prevent them from consuming server resources. In this tutorial, we\u2019ll guide you through the step-by-step process to block bots from Apache via WHM\/cPanel. This method ensures that your website remains secure, loads faster, and avoids unnecessary load caused by bad bots.<\/p>\n\n\n\n<p>When managing a website, dealing with unwanted traffic is a constant challenge. Some of the traffic comes from automated bots that may try to scrape your data, spam your forms, or even launch attacks on your site. If your site is hosted on a cPanel server with Apache, it\u2019s crucial to <strong>block bots<\/strong> effectively to maintain server performance and security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Should You Block Bots?<\/h2>\n\n\n\n<p>While some bots, like search engine crawlers (Googlebot, Bingbot), are beneficial for SEO, others can be harmful. These harmful bots can:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Consume excessive server resources.<\/li>\n\n\n\n<li>Slow down website performance.<\/li>\n\n\n\n<li>Attempt brute force attacks.<\/li>\n\n\n\n<li>Scrape sensitive data.<\/li>\n\n\n\n<li>Skew analytics data with fake traffic.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step-by-Step Guide to Block Bots from Apache via WHM\/cPanel<\/h2>\n\n\n\n<p>Follow these steps to block bots effectively from your Apache server through WHM:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Login to WHM<\/h3>\n\n\n\n<p>First, you need to access your <strong>Web Host Manager (WHM)<\/strong> with root-level credentials.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Enter your <strong>root username and password<\/strong> to log in.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Navigate to Apache Configuration<\/h3>\n\n\n\n<p>Once you are in the WHM dashboard:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the <strong>left sidebar<\/strong>, search for <strong>\u201cApache Configuration.\u201d<\/strong><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"414\" src=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Navigate-to-Apache-Configuration-1024x414.webp\" loading=\"lazy\" alt=\"Navigate to Apache Configuration\" class=\"wp-image-2338\" srcset=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Navigate-to-Apache-Configuration-1024x414.webp 1024w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Navigate-to-Apache-Configuration-300x121.webp 300w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Navigate-to-Apache-Configuration-768x310.webp 768w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Navigate-to-Apache-Configuration-1536x621.webp 1536w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Navigate-to-Apache-Configuration-2048x828.webp 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click on <strong>Apache Configuration<\/strong> > <strong>Include Editor<\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"520\" src=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Include-Editor-1024x520.webp\" loading=\"lazy\" alt=\"Include Editor\" class=\"wp-image-2337\" srcset=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Include-Editor-1024x520.webp 1024w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Include-Editor-300x152.webp 300w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Include-Editor-768x390.webp 768w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Include-Editor-1536x780.webp 1536w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Include-Editor-2048x1040.webp 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The Include Editor allows you to add custom configurations to the Apache server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Edit the Pre-Main Include Section<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the <strong>Apache Include Editor<\/strong>, find the <strong>\u201cPre-Main Include\u201d<\/strong> section.<\/li>\n\n\n\n<li>Select your Apache version (usually <strong>All Versions<\/strong> is safe).<\/li>\n\n\n\n<li>Add the following code snippet to block specific bots:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"332\" src=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Edit-the-Pre-Main-Include-Section-1024x332.webp\" loading=\"lazy\" alt=\"Edit the Pre-Main Include Section\" class=\"wp-image-2340\" srcset=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Edit-the-Pre-Main-Include-Section-1024x332.webp 1024w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Edit-the-Pre-Main-Include-Section-300x97.webp 300w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Edit-the-Pre-Main-Include-Section-768x249.webp 768w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Edit-the-Pre-Main-Include-Section-1536x497.webp 1536w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Edit-the-Pre-Main-Include-Section-2048x663.webp 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Save and Restart Apache<\/h3>\n\n\n\n<p>After adding the code, <strong>click on Update<\/strong> to save the changes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;IfModule mod_rewrite.c>\n    RewriteEngine On\n    # Block Bad Bots\n    RewriteCond %{HTTP_USER_AGENT} ^.*(AhrefsBot|SemrushBot|MJ12bot|DotBot|Baiduspider|YandexBot).*$ &#91;NC]\n    RewriteRule .* - &#91;F,L]\n&lt;\/IfModule><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"357\" src=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Save-and-Restart-Apache-1024x357.webp\" loading=\"lazy\" alt=\"Save and Restart Apache\" class=\"wp-image-2339\" srcset=\"https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Save-and-Restart-Apache-1024x357.webp 1024w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Save-and-Restart-Apache-300x105.webp 300w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Save-and-Restart-Apache-768x268.webp 768w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Save-and-Restart-Apache-1536x536.webp 1536w, https:\/\/hostrago.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Save-and-Restart-Apache.webp 1981w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Then, return to the WHM home screen and <strong>restart the Apache server<\/strong> for the changes to take effect:<\/p>\n\n\n\n<p>Navigate to <strong>Restart Services > HTTP Server (Apache)<\/strong>.<\/p>\n\n\n\n<p>Click <strong>Yes<\/strong> to confirm the restart.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Blocking bots from Apache with WHM\/cPanel is an essential step to maintaining the security, speed, and reliability of your website. By following the above steps, you can easily block unwanted bots that may harm your server resources or website data.<\/p>\n\n\n\n<p>If you are looking for robust hosting solutions with built-in security, check out our services at <strong><a href=\"https:\/\/hostrago.com\/\">Hostrago Hosting<\/a><\/strong>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By using WHM\/cPanel, server administrators can easily implement configurations on the Apache web server to block malicious bots and prevent them from consuming server resources&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":2335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[618,204,619,179,247,494,200],"class_list":["post-2336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpanel","tag-apache-server","tag-block-bots","tag-bot-protection","tag-cpanel","tag-server-optimization","tag-web-security","tag-whm"],"menu_order":0,"_links":{"self":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=2336"}],"version-history":[{"count":1,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2336\/revisions"}],"predecessor-version":[{"id":2341,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/2336\/revisions\/2341"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/media\/2335"}],"wp:attachment":[{"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=2336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=2336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostrago.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=2336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}