{"id":849,"date":"2025-12-19T10:00:31","date_gmt":"2025-12-19T09:00:31","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=849"},"modified":"2026-06-01T09:13:09","modified_gmt":"2026-06-01T07:13:09","slug":"reguli-in-fisierul-htaccess-pentru-a-bloca-robotii-nedoriti","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/","title":{"rendered":"Reguli \u00een fi\u0219ierul .htaccess pentru a bloca robo\u021bii nedori\u021bi"},"content":{"rendered":"<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">The <code>.htaccess<\/code> file is an Apache configuration file that allows you to modify server behavior on a per-directory basis. One common use case is blocking unwanted bots and crawlers that generate unnecessary traffic, consume resources, or attempt malicious activity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before making changes to <code>.htaccess<\/code>, always create a backup of the existing file.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Blocking_a_specific_IP_address\" >Blocking a specific IP address<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Blocking_an_entire_IP_range\" >Blocking an entire IP range<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Blocking_bots_by_User-Agent\" >Blocking bots by User-Agent<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Blocking_multiple_unwanted_User-Agents\" >Blocking multiple unwanted User-Agents<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Blocking_suspicious_User-Agent_headers\" >Blocking suspicious User-Agent headers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Important_considerations\" >Important considerations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Alternative_approaches\" >Alternative approaches<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/rules-in-the-htaccess-file-to-block-unwanted-bots\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Blocking_a_specific_IP_address\"><\/span>Blocking a specific IP address<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<\/div>\n\n<div id=\"mybox-1479127300\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Acces timpuriu<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Mai ave\u021bi nevoie de ajutor?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contacta\u021bi echipa noastr\u0103 de servicii pentru clien\u021bi.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Trimite mesaj<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">If a bot consistently connects from a single IP address, you can block it directly.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Deny from 111.222.333.444\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>111.222.333.444<\/code> with the IP address you want to block.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Blocking_an_entire_IP_range\"><\/span>Blocking an entire IP range<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If unwanted traffic originates from a specific network, you can block the entire range.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Deny from 111.222.333.0\/24\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This example blocks all addresses within the specified subnet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Blocking_bots_by_User-Agent\"><\/span>Blocking bots by User-Agent<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Many bots identify themselves through the <code>User-Agent<\/code> header. You can block a specific bot name using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SetEnvIfNoCase User-Agent \"badbot\" bad_bot\n\nOrder Allow,Deny\nAllow from all\nDeny from env=bad_bot\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, any request containing <code>badbot<\/code> in its User-Agent string will be denied.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Blocking_multiple_unwanted_User-Agents\"><\/span>Blocking multiple unwanted User-Agents<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can block several known bots in a single rule:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SetEnvIfNoCase User-Agent \"(badbot|evilcrawler|spamcrawler)\" bad_bot\n\nOrder Allow,Deny\nAllow from all\nDeny from env=bad_bot\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Blocking_suspicious_User-Agent_headers\"><\/span>Blocking suspicious User-Agent headers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Some automated tools use identifiable User-Agent strings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SetEnvIfNoCase User-Agent \".*(libwww-perl|aesop_com_spiderman)\" HTTP_SAFE_BADBOT\n\nDeny from env=HTTP_SAFE_BADBOT\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Requests matching these patterns will be blocked automatically.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Important_considerations\"><\/span>Important considerations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before implementing bot-blocking rules:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>verify that the bot is genuinely unwanted<\/li>\n\n\n\n<li>avoid blocking legitimate search engine crawlers<\/li>\n\n\n\n<li>test changes after editing <code>.htaccess<\/code><\/li>\n\n\n\n<li>monitor server logs for unintended side effects<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Incorrect rules may block legitimate visitors or affect website functionality.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Alternative_approaches\"><\/span>Alternative approaches<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Depending on your hosting environment, bot management can also be performed using:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>web application firewalls (WAF)<\/li>\n\n\n\n<li>CDN security services<\/li>\n\n\n\n<li>server-level firewall rules<\/li>\n\n\n\n<li>security plugins for CMS platforms<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These solutions often provide more flexibility and easier management than <code>.htaccess<\/code> rules alone.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>.htaccess<\/code> file can be used to block unwanted bots based on IP addresses, IP ranges, User-Agent strings, or suspicious request headers. Properly configured rules can help reduce unwanted traffic and improve server resource usage while protecting your website from abusive crawlers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[10,42],"manual_kb_tag":[1626,1627,1628,1629,1630,1631,1632,1633,1634,444,1635,588,1636,718,1637,780,1638,1088,1639,1165,1640,1173],"class_list":["post-849","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-safety","manualknowledgebasecat-miscellaneous","manual_kb_tag-htaccess","manual_kb_tag-apache-htaccess","manual_kb_tag-htaccess-rules","manual_kb_tag-web-server-security","manual_kb_tag-bot-blocking","manual_kb_tag-block-bots","manual_kb_tag-block-unwanted-bots","manual_kb_tag-ip-range-blocking","manual_kb_tag-deny-rules","manual_kb_tag-access-control","manual_kb_tag-user-agent-filtering","manual_kb_tag-website","manual_kb_tag-user-agent-blocking","manual_kb_tag-htaccess-file","manual_kb_tag-environment-variable-rules","manual_kb_tag-apache-server","manual_kb_tag-apache-configuration-file","manual_kb_tag-ip-address","manual_kb_tag-bad-bot-blocking","manual_kb_tag-apache","manual_kb_tag-ip-address-blocking","manual_kb_tag-ip-blocking"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/849\/revisions"}],"predecessor-version":[{"id":9216,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/849\/revisions\/9216"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/media?parent=849"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manualknowledgebasecat?post=849"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb_tag?post=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}