{"id":34645,"date":"2021-12-29T16:32:34","date_gmt":"2021-12-29T16:32:34","guid":{"rendered":"https:\/\/www.hostduplex.com\/kb\/?post_type=ht_kb&#038;p=34645"},"modified":"2021-12-29T16:32:34","modified_gmt":"2021-12-29T16:32:34","slug":"how-to-use-htaccess-file-to-block-an-ip-address","status":"publish","type":"ht_kb","link":"https:\/\/www.hostduplex.com\/kb\/article\/how-to-use-htaccess-file-to-block-an-ip-address\/","title":{"rendered":"How to use .htaccess file to block an IP address"},"content":{"rendered":"\n<p>If you have problems with certain visitors to your website, you can easily block them by using their IP address or the domain name from which they are visiting.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Here&#8217;s an example that denies a user by their IP address:<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">deny from 111.111.111.111<\/pre>\n\n\n\n<p>When the user tries to connect to your site from that specific IP, they see a 403 Forbidden page instead. If you want to block an entire block of IPs, just leave the last octet off. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">deny from 111.111.111.<\/pre>\n\n\n\n<p>This denies access from anyone using an IP in the range from 111.111.111.0 all the way up to 111.111.111.255.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>In order to block a domain, use the following:<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">SetEnvIfNoCase Referer \"domainname.com\" bad_referer\r\nOrder Allow,Deny\r\nAllow from ALL\r\nDeny from env=bad_referer\r<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-background has-purple-background-color has-purple-color\"\/>\n\n\n\n<p>If you are a Host Duplex customer and still have questions, please open a ticket in the\u00a0<a href=\"https:\/\/secure.hostduplex.com\/clientarea.php\" target=\"_blank\" rel=\"noopener\">Host Duplex client portal.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have problems with certain visitors to your website, you can easily block them by using their IP address or the domain name from which they are visiting. Here&#8217;s an example that denies a user by their IP address: deny from 111.111.111.111 When the user tries to connect to&#8230;<\/p>\n","protected":false},"author":2,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"ht-kb-category":[],"ht-kb-tag":[235,234,187,133],"class_list":["post-34645","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_tag-block-domain","ht_kb_tag-block-ip","ht_kb_tag-htaccess","ht_kb_tag-ip-address"],"_links":{"self":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/comments?post=34645"}],"version-history":[{"count":1,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34645\/revisions"}],"predecessor-version":[{"id":34646,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34645\/revisions\/34646"}],"wp:attachment":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/media?parent=34645"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=34645"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=34645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}