{"id":9371,"date":"2020-05-01T07:07:33","date_gmt":"2020-05-01T07:07:33","guid":{"rendered":"https:\/\/www.milesweb.in\/hosting-faqs\/?p=9371"},"modified":"2026-02-26T18:49:53","modified_gmt":"2026-02-26T13:19:53","slug":"steps-to-block-ip-address-with-htaccess","status":"publish","type":"post","link":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/","title":{"rendered":"Steps to block IP address with .htaccess"},"content":{"rendered":"<p>In this tutorial, we will learn how to deny an IP address or how to allow a particular IP address from accessing your website. This measure is taken to save the website from hackers or to block unwanted visitors.<\/p>\n<p>First of all, you will need to create a .htacsess file in your public_html folder and add the following lines as per the requirements:<\/p>\n<h3>1) Code to deny a specific IP address \u2013<\/h3>\n<pre class=\"trim-whitespace:false lang:default decode:true \">Deny from 192.0.5.1<\/pre>\n<p>This code will deny one IP address from accessing your website. Make sure you use the IP address for which you wish to work.<\/p>\n<h3>2) Code to deny specific domain \u2013<\/h3>\n<pre class=\"trim-whitespace:false lang:default decode:true \">Deny from 192.0.0.1\/366.366.366.0<\/pre>\n<p>Using this code you can deny a specific domain from accessing your domain. Use the code in .htaccess file, and replace IP address and netmask value to match the domain that you wish to block.<\/p>\n<h3>3) Code to deny multiple IP\u2019s in a single line of code \u2013<\/h3>\n<p>While using this code, leave a blank space with each IP for separation.<\/p>\n<pre class=\"trim-whitespace:false lang:default decode:true \">Deny from 111.111.111.111 444.444.444.444 666.666.666.666<\/pre>\n<p>Replace IPs of your choice in .htaccess file.<\/p>\n<h3>4) Code to allow only a single IP \u2013<\/h3>\n<p>The below code will deny access of all the other websites from every IP address except the IP address mentioned in the rule :<\/p>\n<pre class=\"trim-whitespace:false lang:default decode:true \">Order Deny,Allow\r\nDeny from all\r\nAllow from 222.222.222.222<\/pre>\n<p>This code indicates that first, we have denied all visitors and then allowed only the visitor from a specified IP address.<\/p>\n<h3>5) Code to deny single IPv6 address \u2013<\/h3>\n<p>Use the following code to block IPv6 address through .htaccess file :<\/p>\n<pre class=\"trim-whitespace:false lang:default decode:true \">Deny from 2001:cdba:0000:0000:0000:0000:3284:7536<\/pre>\n<p>That\u2019s it!<\/p>\n<p><strong>Also Read :<\/strong><\/p>\n<p><strong>1)\u00a0<a href=\"https:\/\/www.milesweb.in\/hosting-faqs\/learn-to-block-a-user-agent-in-a-htaccess-file\/\" target=\"_blank\" rel=\"noopener\">Learn to Block A User Agent in An .htaccess File<\/a><\/strong><\/p>\n<p><strong>2)\u00a0<a href=\"https:\/\/www.milesweb.in\/hosting-faqs\/common-reasons-website-inaccessible\/\" target=\"_blank\" rel=\"noopener\">What Are The Common Reasons For A Website To Be Inaccessible?<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will learn how to deny an IP address or how to allow a particular IP address from accessing your website. This measure is taken to save the website from hackers or to block unwanted visitors. First of all, you will need to create a .htacsess file in your public_html folder and [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3046],"tags":[672,1423,1422],"class_list":["post-9371","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-files-and-ftp-management","tag-htaccess","tag-block-an-ip-address","tag-block-an-ip-address-with-htaccess"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Steps to block IP address with .htaccess - Web Hosting FAQs by MilesWeb<\/title>\n<meta name=\"description\" content=\"This knowledgebase explains easy steps to block an IP address with .htaccess.\" \/>\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.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Steps to block IP address with .htaccess - Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"og:description\" content=\"This knowledgebase explains easy steps to block an IP address with .htaccess.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-01T07:07:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-26T13:19:53+00:00\" \/>\n<meta name=\"author\" content=\"Sonam Wagh\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sonam Wagh\" \/>\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:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/\"},\"author\":{\"name\":\"Sonam Wagh\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\"},\"headline\":\"Steps to block IP address with .htaccess\",\"datePublished\":\"2020-05-01T07:07:33+00:00\",\"dateModified\":\"2026-02-26T13:19:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/\"},\"wordCount\":269,\"commentCount\":0,\"keywords\":[\".htaccess\",\"block an IP address\",\"block an IP address with .htaccess\"],\"articleSection\":[\"Files &amp; FTP Management\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/\",\"name\":\"Steps to block IP address with .htaccess - Web Hosting FAQs by MilesWeb\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\"},\"datePublished\":\"2020-05-01T07:07:33+00:00\",\"dateModified\":\"2026-02-26T13:19:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\"},\"description\":\"This knowledgebase explains easy steps to block an IP address with .htaccess.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Steps to block IP address with .htaccess\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4\",\"name\":\"Sonam Wagh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg\",\"contentUrl\":\"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg\",\"caption\":\"Sonam Wagh\"},\"description\":\"With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.\",\"url\":\"https:\/\/www.milesweb.in\/hosting-faqs\/author\/sonam\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Steps to block IP address with .htaccess - Web Hosting FAQs by MilesWeb","description":"This knowledgebase explains easy steps to block an IP address with .htaccess.","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.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/","og_locale":"en_US","og_type":"article","og_title":"Steps to block IP address with .htaccess - Web Hosting FAQs by MilesWeb","og_description":"This knowledgebase explains easy steps to block an IP address with .htaccess.","og_url":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2020-05-01T07:07:33+00:00","article_modified_time":"2026-02-26T13:19:53+00:00","author":"Sonam Wagh","twitter_misc":{"Written by":"Sonam Wagh","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#article","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/"},"author":{"name":"Sonam Wagh","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4"},"headline":"Steps to block IP address with .htaccess","datePublished":"2020-05-01T07:07:33+00:00","dateModified":"2026-02-26T13:19:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/"},"wordCount":269,"commentCount":0,"keywords":[".htaccess","block an IP address","block an IP address with .htaccess"],"articleSection":["Files &amp; FTP Management"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/","url":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/","name":"Steps to block IP address with .htaccess - Web Hosting FAQs by MilesWeb","isPartOf":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website"},"datePublished":"2020-05-01T07:07:33+00:00","dateModified":"2026-02-26T13:19:53+00:00","author":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4"},"description":"This knowledgebase explains easy steps to block an IP address with .htaccess.","breadcrumb":{"@id":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/steps-to-block-ip-address-with-htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.in\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"Steps to block IP address with .htaccess"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.in\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.in\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/dc645d02823c86e07e53798ebe02c6f4","name":"Sonam Wagh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.milesweb.in\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg","contentUrl":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-content\/uploads\/2019\/12\/Sonam-Wagh-150x150.jpg","caption":"Sonam Wagh"},"description":"With an interest in doing something creative daily, Sonam works as a Digital Marketing Executive. She likes to write technical blogs related to web hosting, digital marketing, and other IT topics. She also likes to spend her leisure time on social media to find different strategies for client engagement.","url":"https:\/\/www.milesweb.in\/hosting-faqs\/author\/sonam\/"}]}},"_links":{"self":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=9371"}],"version-history":[{"count":1,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9371\/revisions"}],"predecessor-version":[{"id":9372,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/posts\/9371\/revisions\/9372"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=9371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=9371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.in\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=9371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}