{"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-10-29T15:07:56","modified_gmt":"2026-10-29T15:07:56","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 data-click-id=\"hgr-post-content-link-ip-manager\" class=\"intercom-content-link\" href=\"\/support\/1583474-how-to-allow-or-block-a-specific-ip-address-for-your-website-in-hostinger\/\" target=\"_blank\" rel=\"noopener\">IP Manager<\/a><\/b>.<\/p>\n<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>\n<ol>\n<li>\n<p class=\"no-margin\"><b><a data-click-id=\"hgr-post-content-link-create-a-htaccess-file\" class=\"intercom-content-link\" href=\"\/support\/1583307-how-to-create-an-htaccess-file-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">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<\/li>\n<\/ol>\n<h2 id=\"option-1---block-or-allow-specific-ip-addresses\">Option 1 \u2014 Block or allow specific IP addresses<\/h2>\n<p class=\"no-margin\">To set rules for specific addresses, you can use this template:<\/p>\n<pre><code>Order Allow,Deny\r\nDeny from 185.185.185.185\r\nAllow from all<\/code><\/pre>\n<p class=\"no-margin\">In the example above, IP address 185.185.185.185 is blocked and won\u2019t be able to reach your website.<\/p>\n<p class=\"no-margin\">If you want to block several addresses, add them from the new line:<\/p>\n<pre><code>Order Allow,Deny\r\nDeny from 185.185.185.185\r\nDeny from 192.192.192.192<\/code><\/pre>\n<p class=\"no-margin\"><b>NOTE<\/b><\/p>\n<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>\n<h2 id=\"option-2---block-or-allow-ranges-of-ip-addresses\">Option 2 \u2014 Block or allow ranges of IP addresses<\/h2>\n<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>\n<pre><code>Order Allow,Deny \r\nDeny from 185.185.185.0\/24 \r\nAllow from all<\/code><\/pre>\n<p class=\"no-margin\">And by using <b>*<\/b> for the whole octets:<\/p>\n<pre><code>Order Allow,Deny\r\nDeny from 185.185.*.*\r\nAllow from all<\/code><\/pre>\n<p class=\"no-margin\">That&#8217;s it! Now you know how to block or allow IP addresses using .htaccess rules.<\/p>\n<p><strong>Additional resource<\/strong><\/p>\n<ul>\n<li><a data-click-id=\"hgr-post-content-link-how-to-block-visitors-from-countries-using-htaccess\" href=\"\/tutorials\/how-to-block-visitors-from-countries-using-htaccess\/\">How to Block Visitors From Countries Using .htaccess<\/a><\/li>\n<\/ul>\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":{"_content_updated_date":"","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-BR","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-\u044f\u043a-\u0437\u0430\u0431\u043b\u043e\u043a\u0443\u0432\u0430\u0442\u0438-ip-\u0430\u0434\u0440\u0435\u0441\u0438-\u0437\u0430-\u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e","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":3,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1517\/revisions"}],"predecessor-version":[{"id":23394,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1517\/revisions\/23394"}],"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}]}}