{"id":620,"date":"2014-01-21T04:44:25","date_gmt":"2014-01-21T04:44:25","guid":{"rendered":"https:\/\/cpanelplesk.com\/wp62\/?p=620"},"modified":"2021-02-16T12:18:36","modified_gmt":"2021-02-16T12:18:36","slug":"block-an-ip-address-or-country-using-htaccess","status":"publish","type":"post","link":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/","title":{"rendered":"Using .htaccess to block an IP address"},"content":{"rendered":"<p>You can use .htaccess file in order to prevent an access to your webpage from specific IP. A .htaccess is a kind of settings file that can be used for things like establishing password-protected directories and to reduce accessibility based on IP. What other things you can do with .htaccess file, <a title=\"How to Protect Your WordPress Admin Area\" href=\"https:\/\/cpanelplesk.com\/wp62\/how-to-protect-your-wordpress-admin-area\/\">read my posts here.<\/a><br \/>\nTo ban an IP from obtaining your web page, make a .htaccess file within your root folder (usually public_html or www) and add the following settings in the file:<\/p>\n<div class=\"cpanel-files\"><\/div>\n<pre class=\"lang:default decode:true \">order allow,deny\r\ndeny from 32.4.32.33\r\nallow from all<\/pre>\n<div class=\"space1\"><\/div>\n<p>It\u2019s easy to know what exactly is going on here. \u201corder allow,deny\u201d is particularly in this order so that the allow rules are checked first, and if someone receive a deny rule, their server request is rejected (i.e. they are blacklisted).<br \/>\nWithin the example above, we\u2019re blacklisting 127.0.0.1. In actual use, you will need to modify this to the IP address which you wish to blacklist.You can, of course, blacklist several IP details by adding several deny guidelines on a individual line. For example:<\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">order allow,deny\r\ndeny from 93.84.29.121\r\ndeny from 89.32.42.422\r\ndeny from 83.43.2.34\r\ndeny from 12.34.2.44\r\nallow from all<\/pre>\n<\/div>\n<p>If you want to prevent an whole IP range, you can exclude a particular range in the .htaccess rule:<\/p>\n<div class=\"command-sh\">\n<pre class=\"lang:default decode:true \">order allow,deny\r\ndeny from 42.53.1\r\nallow from all<\/pre>\n<\/div>\n<p>This will blacklist IP details in the range of 42.53.1.0 to\u00a042.53.1.0.255<br \/>\nIf\u00a0 you are not easy to use .htaccess file you may use IP deny manager\u00a0available into your cPanel to block access to your website.<br \/>\n<a href=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-630 pleslwp\" src=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg\" alt=\"Ip deny manager\" width=\"539\" height=\"112\" srcset=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg 539w, https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager-300x62.jpg 300w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/a>You may start by adding the IP into IP Address or Domain box after that page can refresh with the notification that Ip address will not be able to access your site.<br \/>\nWe have blocked a single IP, multiple IPs and a whole range so far. Whats about blocked a whole country? There are many different IPs blocks that are assigned to a country and it is difficult for any one to short that out by himself. The good thing here is there are several sites that can help us in obtaining a .htaccess optimized IP blocks of any country. <a href=\"http:\/\/www.ip2location.com\/free\/visitor-blocker\">ip2location<\/a> is such a website, you can simply visit it, select the country and then copy paste the whole long output in your .htaccess file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can use .htaccess file in order to prevent an access to your webpage from specific IP. A .htaccess is a kind of settings file that can be used for things like establishing password-protected directories and to reduce accessibility based on IP. What other things you can do with .htaccess file, read my posts here. [&#8230;]<\/p>\n<p><a class=\"understrap-read-more-link\" href=\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/\">Continue Reading&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-620","post","type-post","status-publish","format-standard","hentry","category-cpanel"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using .htaccess to block an IP address - cPanel Plesk<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Using .htaccess to block an IP address - cPanel Plesk\" \/>\n<meta name=\"twitter:description\" content=\"You can use .htaccess file in order to prevent an access to your webpage from specific IP. A .htaccess is a kind of settings file that can be used for things like establishing password-protected directories and to reduce accessibility based on IP. What other things you can do with .htaccess file, read my posts here. [...]Continue Reading...\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Seemab Saleem\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/\"},\"author\":{\"name\":\"Seemab Saleem\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\"},\"headline\":\"Using .htaccess to block an IP address\",\"datePublished\":\"2014-01-21T04:44:25+00:00\",\"dateModified\":\"2021-02-16T12:18:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/\"},\"wordCount\":360,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg\",\"articleSection\":[\"Cpanel\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/\",\"name\":\"Using .htaccess to block an IP address - cPanel Plesk\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg\",\"datePublished\":\"2014-01-21T04:44:25+00:00\",\"dateModified\":\"2021-02-16T12:18:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg\",\"width\":539,\"height\":112},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cpanelplesk.com\/wp62\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using .htaccess to block an IP address\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/\",\"name\":\"cPanel Plesk\",\"description\":\"Blog on famous hosting control panels\",\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\",\"name\":\"Farooq Omer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"width\":300,\"height\":44,\"caption\":\"Farooq Omer\"},\"logo\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\",\"name\":\"Seemab Saleem\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"caption\":\"Seemab Saleem\"},\"description\":\"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!\",\"sameAs\":[\"https:\/\/cpanelplesk.com\/wp62\"],\"url\":\"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using .htaccess to block an IP address - cPanel Plesk","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:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/","twitter_card":"summary_large_image","twitter_title":"Using .htaccess to block an IP address - cPanel Plesk","twitter_description":"You can use .htaccess file in order to prevent an access to your webpage from specific IP. A .htaccess is a kind of settings file that can be used for things like establishing password-protected directories and to reduce accessibility based on IP. What other things you can do with .htaccess file, read my posts here. [...]Continue Reading...","twitter_image":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg","twitter_misc":{"Written by":"Seemab Saleem","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#article","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/"},"author":{"name":"Seemab Saleem","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648"},"headline":"Using .htaccess to block an IP address","datePublished":"2014-01-21T04:44:25+00:00","dateModified":"2021-02-16T12:18:36+00:00","mainEntityOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/"},"wordCount":360,"commentCount":1,"publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg","articleSection":["Cpanel"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/","url":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/","name":"Using .htaccess to block an IP address - cPanel Plesk","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg","datePublished":"2014-01-21T04:44:25+00:00","dateModified":"2021-02-16T12:18:36+00:00","breadcrumb":{"@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#primaryimage","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2014\/01\/Ip-deny-manager.jpg","width":539,"height":112},{"@type":"BreadcrumbList","@id":"https:\/\/cpanelplesk.com\/wp62\/block-an-ip-address-or-country-using-htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cpanelplesk.com\/wp62\/"},{"@type":"ListItem","position":2,"name":"Using .htaccess to block an IP address"}]},{"@type":"WebSite","@id":"https:\/\/cpanelplesk.com\/wp62\/#website","url":"https:\/\/cpanelplesk.com\/wp62\/","name":"cPanel Plesk","description":"Blog on famous hosting control panels","publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13","name":"Farooq Omer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","width":300,"height":44,"caption":"Farooq Omer"},"logo":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648","name":"Seemab Saleem","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","caption":"Seemab Saleem"},"description":"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!","sameAs":["https:\/\/cpanelplesk.com\/wp62"],"url":"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/"}]}},"_links":{"self":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/comments?post=620"}],"version-history":[{"count":0,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/620\/revisions"}],"wp:attachment":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media?parent=620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/categories?post=620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/tags?post=620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}