{"id":485,"date":"2012-11-27T21:21:08","date_gmt":"2012-11-27T21:21:08","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/11\/27\/block-unwanted-users-from-your-site-using-htaccess\/"},"modified":"2021-11-05T18:27:37","modified_gmt":"2021-11-05T22:27:37","slug":"block-unwanted-users-from-your-site-using-htaccess","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/","title":{"rendered":"Block unwanted users from your site using .htaccess"},"content":{"rendered":"<p>In this article we\u2019ll discuss how you can <strong>block unwanted users<\/strong> or bots from accessing your website via <strong>.htaccess<\/strong> rules. The .<strong>htaccess<\/strong> file is a hidden file on the server that can be used to control access to your website among other features.<\/p>\n\n\n\n<p>Following the steps below we\u2019ll walk through several different ways in which you can block unwanted users from being able to access your website.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"#edit-htaccess\">Edit your .htaccess file<\/a><\/li><li><a href=\"#block-by-ip\">Block by IP address<\/a><ul><li><a href=\"#single-ip\">Block a single IP address<\/a><\/li><li><a href=\"#range-ip\">Block a range of IP addresses<\/a><\/li><\/ul><\/li><li><a href=\"#block-by-user-agent\">Block bad users based on their User-Agent string<\/a><ul><li><a href=\"#single-agent\">Block a single bad User-Agent<\/a><\/li><li><a href=\"#multi-agent\">Block multiple bad User-Agents<\/a><\/li><\/ul><\/li><li><a href=\"#block-by-referer\">Block by referer<\/a><ul><li><a href=\"#single-referer\">Block a single bad referer<\/a><\/li><li><a href=\"#multi-referer\">Block multiple bad referers<\/a><\/li><\/ul><\/li><li><a href=\"#block-bots\">Temporarily block bad bots<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"edit-htaccess\">Edit your .htaccess file<\/h2>\n\n\n\n<p>To use any of the forms of blocking an unwanted user from your website, you\u2019ll need to edit your <strong>.htaccess<\/strong> file.<\/p>\n\n\n\n<ol class=\"article_list wp-block-list\"><li><a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/cpanel\/how-to-log-into-cpanel\/\">Login to your cPanel<\/a>.<\/li><li>Under <strong>Files<\/strong>, click on <strong>File Manager<\/strong>.<br><img decoding=\"async\" width=\"902\" height=\"256\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png\" class=\"optimized-lcp-image\" alt=\"cPanel file manager\" loading=\"eager\" fetchpriority=\"high\" sizes=\"(max-width: 768px) 100vw, 768px\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png 902w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02-300x85.png 300w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02-768x218.png 768w\"><\/li><li>Click on <strong>Settings<\/strong> in the upper-right. Be sure that <em>Show Hidden Files (dotfiles)<\/em> is checked. Click <strong>Save<\/strong>.<br><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"382\" class=\"wp-image-91243\" style=\"width: 650px;\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-03.png\" alt=\"cPanel file manager settings\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-03.png 1258w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-03-300x176.png 300w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-03-1024x602.png 1024w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-03-768x452.png 768w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/li><li>Select the directory for the site you want to edit. Please note that if the site is your primary domain, you will select <strong>public_html<\/strong>.<\/li><li>If your site is missing an .htaccess file, click on <strong>+ File<\/strong> at the top-left and name the file .htaccess. Be sure the listed directory matches the site you are working on and click <strong>Create New File<\/strong>.<\/li><li>If your .htaccess file already exists, or you\u2019ve finished creating one, right-click on the .htaccess file and select <strong>Edit<\/strong>.<br><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"301\" class=\"wp-image-91245\" style=\"width: 650px;\" src=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-06.png\" alt=\"cpanel editing htaccess\" srcset=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-06.png 644w, https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-06-300x139.png 300w\" sizes=\"auto, (min-width: 1360px) 876px, (min-width: 960px) calc(61.58vw + 51px), calc(100vw - 80px)\" \/><\/li><li>You might have a text editor encoding dialog box pop-up, you can simply click on <strong>Edit<\/strong>.<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-by-ip\">Block by IP address<\/h2>\n\n\n\n<p>You might have one particular IP address, or multiple IP addresses that are causing a problem on your website. In this event, you can simply outright block these problematic IP addresses from accessing your site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"single-ip\">Block a single IP address<\/h3>\n\n\n\n<p>If you just need to block a single IP address, or multiple IPs not in the same range, you can do so with this rule:<\/p>\n\n\n\n<p><code>deny from 123.123.123.123<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"range-ip\">Block a range of IP addresses<\/h3>\n\n\n\n<p>To block an IP range, such as <strong>123.123.123.1 \u2013 123.123.123.255<\/strong>, you can leave off the last octet:<\/p>\n\n\n\n<p><code>deny from 123.123.123<\/code><\/p>\n\n\n\n<p>You can also use CIDR (Classless Inter-Domain Routing) notation for blocking IPs:<\/p>\n\n\n\n<p>To block the range <strong>123.123.123.1 \u2013 123.123.123.255<\/strong>, use <strong>123.123.123.0\/24<\/strong><\/p>\n\n\n\n<p>To block the range <strong>123.123.64.1 \u2013 123.123.127.255<\/strong>, use <strong>123.123.123.0\/18<\/strong><\/p>\n\n\n\n<p><code>deny from 123.123.123.0\/24<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-by-user-agent\">Block bad users based on their User-Agent string<\/h2>\n\n\n\n<p>Some malicious users will send requests from different IP addresses, but still using the same User-Agent for sending all of the requests. In these events you can also block users by their User-Agent strings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"single-agent\">Block a single bad User-Agent<\/h3>\n\n\n\n<p>If you just wanted to block one particular User-Agent string, you could use this RewriteRule:<\/p>\n\n\n\n<p><code>RewriteEngine On RewriteCond %{HTTP_USER_AGENT} Baiduspider [NC] RewriteRule .* - [F,L]<\/code><\/p>\n\n\n\n<p>Alternatively, you can also use the <code>BrowserMatchNoCase<\/code> Apache directive like this:<\/p>\n\n\n\n<p><code>BrowserMatchNoCase \"Baiduspider\" bots Order Allow,Deny Allow from ALL Deny from env=bots<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"multi-agent\">Block multiple bad User-Agents<\/h3>\n\n\n\n<p>If you wanted to block multiple User-Agent strings at once, you could do it like this:<\/p>\n\n\n\n<p><code>RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|HTTrack|Yandex).*$ [NC] RewriteRule .* - [F,L]<\/code><\/p>\n\n\n\n<p>Or you can also use the <a href=\"https:\/\/httpd.apache.org\/docs\/2.2\/mod\/mod_setenvif.html\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>BrowserMatchNoCase<\/strong><\/a> directive like this:<\/p>\n\n\n\n<p><code>BrowserMatchNoCase \"Baiduspider\" bots BrowserMatchNoCase \"HTTrack\" bots BrowserMatchNoCase \"Yandex\" bots Order Allow,Deny Allow from ALL Deny from env=bots<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-by-referer\">Block by referer<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"single-referer\">Block a single bad referer<\/h3>\n\n\n\n<p>If you just wanted to block a single bad referer like <strong>example.com<\/strong> you could use this RewriteRule:<\/p>\n\n\n\n<p><code>RewriteEngine On RewriteCond %{HTTP_REFERER} example.com [NC] RewriteRule .* - [F]<\/code><\/p>\n\n\n\n<p>Alternatively, you could also use the <a href=\"https:\/\/httpd.apache.org\/docs\/2.2\/mod\/mod_setenvif.html\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>SetEnvIfNoCase<\/strong><\/a> Apache directive like this:<\/p>\n\n\n\n<p><code>SetEnvIfNoCase Referer \"example.com\" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"multi-referer\">Block multiple bad referers<\/h3>\n\n\n\n<p>If you just wanted to block multiple referers like example.com and example.net you could use:<\/p>\n\n\n\n<p><code>RewriteEngine On RewriteCond %{HTTP_REFERER} example.com [NC,OR] RewriteCond %{HTTP_REFERER} example.net [NC]RewriteRule .* - [F]<\/code><\/p>\n\n\n\n<p>Or you can also use the <strong>SetEnvIfNoCase<\/strong> Apache directive like this:<\/p>\n\n\n\n<p><code>SetEnvIfNoCase Referer \"example.com\" bad_referer SetEnvIfNoCase Referer \"example.net\" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-bots\">Temporarily block bad bots<\/h2>\n\n\n\n<p>In some cases you might not want to send a 403 response to a visitor which is just a access denied message. A good example of this is lets say your site is getting a large spike in traffic for the day from a promotion you\u2019re running, and you don\u2019t want some good search engine bots like Google or Yahoo to come along and start to index your site during that same time that you might already be stressing the server with your extra traffic.<\/p>\n\n\n\n<p>The following code will setup a basic error document page for a 503 response, this is the default way to tell a search engine that their request is temporarily blocked and they should try back at a later time. This is different then denying them access temporarily via a 403 response, as with a 503 response Google has confirmed they will come back and try to index the page again instead of dropping it from their index.<\/p>\n\n\n\n<p>The following code will grab any requests from user-agents that have the words <strong>bot<\/strong>, <strong>crawl<\/strong>, or <strong>spider<\/strong> in them which most of the major search engines will match for. The 2nd <strong>RewriteCond<\/strong> line allows these bots to still request a <strong>robots.txt<\/strong> file to check for new rules, but any other requests will simply get a 503 response with the message \u201c<strong>Site temporarily disabled for crawling<\/strong>\u201d.<\/p>\n\n\n\n<p class=\"alert alert-info\">Typically you don\u2019t want to leave a 503 block in place for longer than 2 days. Otherwise Google might start to interpret this as an extended server outage and could begin to remove your URLs from their index.<\/p>\n\n\n\n<p><code>ErrorDocument 503 \"Site temporarily disabled for crawling\" RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^.*(bot|crawl|spider).*$ [NC] RewriteCond %{REQUEST_URI} !^\/robots.txt$ RewriteRule .* - [R=503,L]<\/code><\/p>\n\n\n\n<p>This method is good to use if you notice some new bots crawling your site causing excessive requests and you want to block them or slow them down via your <strong>robots.txt<\/strong> file. As it will let you 503 their requests until they read your new <strong>robots.txt<\/strong> rules and start obeying them. You can read about <a href=\"https:\/\/www.inmotionhosting.com\/support\/website\/how-to-stop-search-engines-from-crawling-your-website\/\">how to stop search engines from crawling your website<\/a> for more information regarding this.<\/p>\n\n\n\n<p>You should now understand how to use a <strong>.htaccess<\/strong> file to help block access to your website in multiple ways.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article we\u2019ll discuss how you can block unwanted users or bots from accessing your website via .htaccess rules. The .htaccess file is a hidden file on the server that can be used to control access to your website among other features. Following the steps below we\u2019ll walk through several different ways in which<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4288],"tags":[],"class_list":["post-485","post","type-post","status-publish","format-standard","hentry","category-website"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Block unwanted users from your site using .htaccess | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article we&#039;ll discuss how you can block unwanted users or bots from accessing your website via .htaccess rules.\" \/>\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.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Block unwanted users from your site using .htaccess | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article we&#039;ll discuss how you can block unwanted users or bots from accessing your website via .htaccess rules.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-27T21:21:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-05T22:27:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"Block unwanted users from your site using .htaccess\",\"datePublished\":\"2012-11-27T21:21:08+00:00\",\"dateModified\":\"2021-11-05T22:27:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\"},\"wordCount\":917,\"commentCount\":62,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png\",\"articleSection\":[\"Website\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\",\"name\":\"Block unwanted users from your site using .htaccess | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png\",\"datePublished\":\"2012-11-27T21:21:08+00:00\",\"dateModified\":\"2021-11-05T22:27:37+00:00\",\"description\":\"In this article we'll discuss how you can block unwanted users or bots from accessing your website via .htaccess rules.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png\",\"width\":902,\"height\":256,\"caption\":\"cPanel file manager\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Block unwanted users from your site using .htaccess\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Block unwanted users from your site using .htaccess | InMotion Hosting","description":"In this article we'll discuss how you can block unwanted users or bots from accessing your website via .htaccess rules.","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.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/","og_locale":"en_US","og_type":"article","og_title":"Block unwanted users from your site using .htaccess | InMotion Hosting","og_description":"In this article we'll discuss how you can block unwanted users or bots from accessing your website via .htaccess rules.","og_url":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2012-11-27T21:21:08+00:00","article_modified_time":"2021-11-05T22:27:37+00:00","og_image":[{"url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png","type":"","width":"","height":""}],"author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"Block unwanted users from your site using .htaccess","datePublished":"2012-11-27T21:21:08+00:00","dateModified":"2021-11-05T22:27:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/"},"wordCount":917,"commentCount":62,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png","articleSection":["Website"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/","url":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/","name":"Block unwanted users from your site using .htaccess | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png","datePublished":"2012-11-27T21:21:08+00:00","dateModified":"2021-11-05T22:27:37+00:00","description":"In this article we'll discuss how you can block unwanted users or bots from accessing your website via .htaccess rules.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#primaryimage","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2012\/11\/blockunwantedusers-02.png","width":902,"height":256,"caption":"cPanel file manager"},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/website\/block-unwanted-users-from-your-site-using-htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Block unwanted users from your site using .htaccess"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4288,"name":"Website","slug":"website","link":"https:\/\/www.inmotionhosting.com\/support\/website\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=485"}],"version-history":[{"count":11,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/485\/revisions"}],"predecessor-version":[{"id":91246,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/485\/revisions\/91246"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}