{"id":4075,"date":"2013-07-10T12:24:36","date_gmt":"2013-07-10T12:24:36","guid":{"rendered":"https:\/\/bodhost.com\/kb\/?p=4075"},"modified":"2026-02-26T14:04:32","modified_gmt":"2026-02-26T14:04:32","slug":"how-to-block-bad-bots","status":"publish","type":"post","link":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/","title":{"rendered":"How to Block Bad Bots?"},"content":{"rendered":"\r\n<p>Before you proceed to block bad bots, you will need to know at least one of two things: IP addresses from where the bots are coming or the User Agent String which bots are using. The easiest way to find this is to look into your raw web logs or AWstats.<\/p>\r\n\r\n\r\n\r\n<p>For your information, the IP address is a series of 4 numbers separated by dots. They look like this \u201c127.0.0.1\u201d<\/p>\r\n\r\n\r\n\r\n<p>The User-Agent String is just the name that the program accessing your website goes by. For example, version 9.51 of the Opera web browser has a user agent string of Opera\/9.51 (Windows NT 5.1; U; en) among others. While the Google search engine bots go by Googlebot\/2.1.<\/p>\r\n\r\n\r\n\r\n<p>You will not need to know the entire user-agent strings. Just find some part of the user agent string which is unique to that specific bot and no other bot or web browser uses.<\/p>\r\n\r\n\r\n\r\n<p>Note down the IP addresses used by the bots and the user agent string. Once you have noted down the IP addresses used by the bots. And the user agent string, you can follow either any one of the following step or you can use both steps. Using both steps recommended for better security.<\/p>\r\n\r\n\r\n\r\n<ol>\r\n<li><strong><strong>Blocking Bad Bots by using IP<br \/><\/strong><\/strong>\r\n<p>You can block bots by using IP addresses. Just enter the following code under your .htaccess file.<\/p>\r\n<p><code>Code:<br \/>\r\nOrder Deny, Allow<br \/>\r\nDeny from IP address<\/code><\/p>\r\n<p>But if you have more than one IP addresses to block. Just add another \u201cDeny from\u201d line with that IP address underneath.<\/p>\r\n<p><code>Code:<br \/>\r\nOrder Deny, Allow<br \/>\r\nDeny from IP address<br \/>\r\nDeny from IP address<\/code><\/p>\r\n<p><code>For example:<br \/>\r\nroot@support[~]# vi .htaccess<br \/>\r\nDeny an IP address.<br \/>\r\nOrder allow, deny<br \/>\r\nDeny from 79.133.196.50 Specific IP address<br \/>\r\nDeny from 79.133.196.50\/32 Subnet range<br \/>\r\nDeny from 196.50.* Wildcard IP address<br \/>\r\nAllow from all<\/code><\/p>\r\n<p>You also block a country by using the mod_geoip module which compiled into Apache on the build.<\/p>\r\n<p><code>Edit your .htaccess file<br \/>\r\nGeoIP ON<br \/>\r\nSetEnvIF GEOIP_COUNTRY_CODE CN BlockThese<br \/>\r\nSetEnvIF GEOIP_COUNTRY_CODE TR BlockThese<br \/>\r\n# Add more countries here<br \/>\r\nDeny from env=BlockThese<\/code><\/p>\r\n<blockquote class=\"wp-block-quote\">\r\n<p>A full list of 2 digit country codes can be found here:<br \/>http:\/\/www.iso.org\/iso\/country_codes\/iso_3166_code_lists\/country_names_and_code_elements<\/p>\r\n<\/blockquote>\r\n<p><strong>The country code mentioned in the above example are CN = China and TR = Turkey<\/strong><\/p>\r\n<p>Note: There is no representation of how your website will perform if you add blocks to your website. Keep in mind that the larger the .htaccess file. The slower your website loading will be as it has to process files on each loading.<\/p>\r\n<p>IP numbers change and or added to certain country ranges. You will need to remember to update the list accordingly.<\/p>\r\n<\/li>\r\n<li><strong><strong>Blocking the bad bots by using User Agent String:<br \/><\/strong><\/strong>\r\n<p>You can place the following code at the bottom of your .htaccess file. If you do not already have a file called .htaccess in your website\u2019s root directory. Then you can create a new one.<\/p>\r\n<strong><strong>\r\n\r\n<\/strong><\/strong>\r\n<p><code>Code:<br \/>\r\n#get rid of the bad bot<br \/>\r\nRewriteEngine on<br \/>\r\nRewriteCond %{ HTTP_USER_AGENT} ^BadBot<br \/>\r\nRewriteRule ^ (.*) $ http:\/\/go.away\/<\/code><\/p>\r\n<strong><strong>\r\n\r\n<\/strong><\/strong>\r\n<p>The above lines tell your web server to check for any bot whose user-agent string starts with &#8220;BadBot&#8221;.<\/p>\r\n<strong><strong>\r\n\r\n<\/strong><\/strong>\r\n<p><strong>To block more than one badbot, follow the below steps:<\/strong><\/p>\r\n<strong><strong>\r\n\r\n<\/strong><\/strong>\r\n<p><code>Code:<br \/>\r\n#get rid of bad bots<br \/>\r\nRewriteEngine on<br \/>\r\nRewriteCond %{ HTTP_USER_AGENT} ^BadBot [OR]<br \/>\r\nRewriteCond %{ HTTP_USER_AGENT} ^EvilScraper [OR]<br \/>\r\nRewriteCond %{ HTTP_USER_AGENT} ^FakeUser<br \/>\r\nRewriteRule ^ (.*) $ http:\/\/go.away\/<\/code><\/p>\r\n<strong><strong>\r\n\r\n<\/strong><\/strong>\r\n<p>Note: You can replace \u201cBadBot\u201d \u201cEvilScraper\u201d and \u201cFakeUser\u201d with the User Agent String that you find in logs. If you implement the method described above, you will be able to block specific bad bots from accessing your website by either their IP addresses or their User Agent String.<\/p>\r\n<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>Before you proceed to block bad bots, you will need to know at least one of two things: IP addresses from where the bots are coming or the User Agent&hellip;<\/p>\n<p><a href=\"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/\" class=\"more-link\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[666],"tags":[522,521],"class_list":["post-4075","post","type-post","status-publish","format-standard","hentry","category-general","tag-block-user-agent-string","tag-blocking-bad-bots"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Detect and Block Bad Bots Effectively<\/title>\n<meta name=\"description\" content=\"IP addresses from where the bots are coming or the User Agent String which bots are using.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Detect and Block Bad Bots Effectively\" \/>\n<meta property=\"og:description\" content=\"IP addresses from where the bots are coming or the User Agent String which bots are using.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowledge Base - bodHOST\" \/>\n<meta property=\"article:published_time\" content=\"2013-07-10T12:24:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-26T14:04:32+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/c48414ad1536cea20e85282b0737a9f9\"},\"headline\":\"How to Block Bad Bots?\",\"datePublished\":\"2013-07-10T12:24:36+00:00\",\"dateModified\":\"2026-02-26T14:04:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/\"},\"wordCount\":494,\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"keywords\":[\"block user agent string\",\"blocking bad bots\"],\"articleSection\":[\"General Discussion\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/\",\"name\":\"How to Detect and Block Bad Bots Effectively\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\"},\"datePublished\":\"2013-07-10T12:24:36+00:00\",\"dateModified\":\"2026-02-26T14:04:32+00:00\",\"description\":\"IP addresses from where the bots are coming or the User Agent String which bots are using.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/how-to-block-bad-bots\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"General Discussion\",\"item\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/category\\\/general\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Block Bad Bots?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\"},\"alternateName\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#organization\",\"name\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"contentUrl\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/wp-content\\\/uploads\\\/2025\\\/10\\\/Profile-Pic.png\",\"width\":240,\"height\":240,\"caption\":\"Web Hosting Knowledge Base | bodHOST Hosting FAQ\"},\"image\":{\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/#\\\/schema\\\/person\\\/c48414ad1536cea20e85282b0737a9f9\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\\\/\\\/www.bodhost.com\\\/kb\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Detect and Block Bad Bots Effectively","description":"IP addresses from where the bots are coming or the User Agent String which bots are using.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/","og_locale":"en_US","og_type":"article","og_title":"How to Detect and Block Bad Bots Effectively","og_description":"IP addresses from where the bots are coming or the User Agent String which bots are using.","og_url":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/","og_site_name":"Knowledge Base - bodHOST","article_published_time":"2013-07-10T12:24:36+00:00","article_modified_time":"2026-02-26T14:04:32+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/#article","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/"},"author":{"name":"admin","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/c48414ad1536cea20e85282b0737a9f9"},"headline":"How to Block Bad Bots?","datePublished":"2013-07-10T12:24:36+00:00","dateModified":"2026-02-26T14:04:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/"},"wordCount":494,"publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"keywords":["block user agent string","blocking bad bots"],"articleSection":["General Discussion"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/","url":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/","name":"How to Detect and Block Bad Bots Effectively","isPartOf":{"@id":"https:\/\/www.bodhost.com\/kb\/#website"},"datePublished":"2013-07-10T12:24:36+00:00","dateModified":"2026-02-26T14:04:32+00:00","description":"IP addresses from where the bots are coming or the User Agent String which bots are using.","breadcrumb":{"@id":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.bodhost.com\/kb\/how-to-block-bad-bots\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"General Discussion","item":"https:\/\/www.bodhost.com\/kb\/category\/general\/"},{"@type":"ListItem","position":2,"name":"How to Block Bad Bots?"}]},{"@type":"WebSite","@id":"https:\/\/www.bodhost.com\/kb\/#website","url":"https:\/\/www.bodhost.com\/kb\/","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","description":"","publisher":{"@id":"https:\/\/www.bodhost.com\/kb\/#organization"},"alternateName":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bodhost.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.bodhost.com\/kb\/#organization","name":"Web Hosting Knowledge Base | bodHOST Hosting FAQ","url":"https:\/\/www.bodhost.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","contentUrl":"https:\/\/www.bodhost.com\/kb\/wp-content\/uploads\/2025\/10\/Profile-Pic.png","width":240,"height":240,"caption":"Web Hosting Knowledge Base | bodHOST Hosting FAQ"},"image":{"@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.bodhost.com\/kb\/#\/schema\/person\/c48414ad1536cea20e85282b0737a9f9","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/51e53199212db3f59606920448d45a6ead224f904558e3ab9251d071a609b202?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/www.bodhost.com\/kb\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/4075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/comments?post=4075"}],"version-history":[{"count":20,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/4075\/revisions"}],"predecessor-version":[{"id":12228,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/posts\/4075\/revisions\/12228"}],"wp:attachment":[{"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/media?parent=4075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/categories?post=4075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bodhost.com\/kb\/wp-json\/wp\/v2\/tags?post=4075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}