{"id":1517,"date":"2019-02-08T10:35:57","date_gmt":"2019-02-08T10:35:57","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2019\/02\/08\/1583355-how-to-block-an-ip-using-the-htaccess-file-at-hostinger\/"},"modified":"2026-03-16T12:12:17","modified_gmt":"2026-03-16T12:12:17","slug":"1583355-how-to-block-an-ip-using-the-htaccess-file-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/1583355-how-to-block-an-ip-using-the-htaccess-file-at-hostinger\/","title":{"rendered":"How to Block an IP Using the .htaccess File at Hostinger"},"content":{"rendered":"<p class=\"no-margin\">If you want to block or whitelist specific IP addresses, you can do it with an <b><a href=\"\/support\/1583474-how-can-i-allow-or-block-a-specific-ip-address-for-my-website\" target=\"_blank\" class=\"intercom-content-link\">IP Manager<\/a><\/b>.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">If you prefer doing changes via <b>.htaccess<\/b> or you want to create settings for a list of addresses, all you need to do is: <\/p><ol>\n<li>\n<p class=\"no-margin\"><b><a href=\"\/support\/1583307-how-to-create-an-htaccess-file\" target=\"_blank\" class=\"intercom-content-link\">Create a .htaccess file<\/a><\/b> in your <b>public_html<\/b> folder <\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">Add lines based on your preferences<\/p>\n<p class=\"no-margin\">\n<\/p><\/li>\n<\/ol><h2 id=\"option-1---block-or-allow-specific-ip-addresses\">Option 1 &mdash; Block or allow specific IP addresses<\/h2><p class=\"no-margin\">To set rules for specific addresses, you can use this template:<\/p><pre><code>Order Allow,Deny<br>Deny from 185.185.185.185<br>Allow from all<\/code><\/pre><p class=\"no-margin\">In the example above, IP address 185.185.185.185 is blocked and won&rsquo;t be able to reach your website. <\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">If you want to block several addresses, add them from the new line: <\/p><pre><code>Order Allow,Deny<br>Deny from 185.185.185.185<br>Deny from 192.192.192.192<\/code><\/pre><p class=\"no-margin\">\n<\/p><p class=\"no-margin\"><b>NOTE<\/b><\/p><ul>\n<li>\n<p class=\"no-margin\">The <code>Allow from<\/code> line is optional if you only want to deny access and vice versa<\/p>\n<\/li>\n<\/ul><p class=\"no-margin\">\n<\/p><h2 id=\"option-2---block-or-allow-ranges-of-ip-addresses\">Option 2 &mdash; Block or allow ranges of IP addresses<\/h2><p class=\"no-margin\">You can set rules for whole ranges or subnets of IP addresses by setting from-to values in IP address:<\/p><pre><code>Order Allow,Deny <br>Deny from 185.185.185.0\/24 <br>Allow from all<\/code><\/pre><p class=\"no-margin\">And by using <b>*<\/b> for the whole octets:<\/p><pre><code>Order Allow,Deny<br>Deny from 185.185.*.*<br>Allow from all<\/code><\/pre><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">That&rsquo;s it! Now you know how to block or allow IP addresses using .htaccess rules &#128522; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Blocking IP addresses with the help of the .htaccess file<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[263],"tags":[],"class_list":["post-1517","post","type-post","status-publish","format-standard","hentry","category-other"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/1583355-how-to-block-an-ip-using-the-htaccess-file-at-hostinger\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/1583355-como-bloquear-direcciones-ip-usando-el-archivo-htaccess-en-hostinger\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/1583355-comment-bloquer-l-ip-en-utilisant-le-fichier-htaccess-hostinger\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/1583355-bagaimana-cara-memblokir-ip-menggunakan-file-htaccess-hostinger\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/br\/support\/1583355-como-bloquear-um-ip-pelo-arquivo-htaccess-hostinger\/","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/1583355---ip---\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=1517"}],"version-history":[{"count":0,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1517\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}