{"id":143,"date":"2021-06-11T14:41:12","date_gmt":"2021-06-11T14:41:12","guid":{"rendered":"http:\/\/tiruppurwebhosting.com\/blog\/?p=143"},"modified":"2021-06-11T15:05:53","modified_gmt":"2021-06-11T15:05:53","slug":"steps-to-block-ip-addresses-with-htaccess-file","status":"publish","type":"post","link":"https:\/\/tiruppurwebhosting.com\/blog\/steps-to-block-ip-addresses-with-htaccess-file\/","title":{"rendered":"Steps to Block IP Addresses with .htaccess file."},"content":{"rendered":"<h1>Steps to Block IP Addresses with .htaccess file<\/h1>\n<p>Here in this post i am going to explain how to deny an IP address or how to allow only a particular IP address to access your site<\/p>\n<p>This will helps and useful for you to protect your websites from hackers or to block any unwanted visitors.<\/p>\n<p>For this you need to create an .htaccess file in your public_html folder and add these lines below, based on your requirements.<\/p>\n<h4>To Deny a Specific\u00a0IP Address<\/h4>\n<p>Type the below code it will only deny one IP address from accessing the website.<\/p>\n<pre>\u200b\u200bDeny from 185.0.0.1<\/pre>\n<p>Just change the above IP address to the IP address that you want to deny and paste it in the .htaccess file.<\/p>\n<h4>To Deny a Specific Domain<\/h4>\n<p>We can able to deny a specific domain from accessing our <a href=\"https:\/\/www.squarebrothers.com\/domain-registration-india\/\" target=\"_blank\" rel=\"noopener\">domains<\/a> by adding the below line of code to your .htaccess file.<\/p>\n<pre>Deny from 185.0.0.1\/255.255.255.0<\/pre>\n<p>You need to change the IP address and netmask value to match the domain that you want to block.<\/p>\n<h4>To Deny Multiple IP\u2019s in a Single Line of Code<\/h4>\n<p>For this you leave a blank space with each IP for separation.<\/p>\n<pre>\u200bDeny from 111.111.111.111 222.222.222.222 333.333.333.333<\/pre>\n<p>All you need to do is replace the IPs that you want to deny and paste it in the .htaccess file.<\/p>\n<h4>To Allow Only a Single IP<\/h4>\n<p>The below set of .htaccess rule will deny access to your website from every IP address expect the IP address mentioned in the rule.<\/p>\n<pre>Order Deny,Allow\r\nDeny from all\r\nAllow from 111.111.111.111<\/pre>\n<p>Here we first deny all visitors, and then allow only the visitor from the IP address specified above.<\/p>\n<p>To check log entries for total no of connections to a Port From an IP Address.<a href=\"https:\/\/www.coimbatorewebhosting.com\/blog\/making-log-entries-for-total-no-of-connections-to-a-port-from-an-ip-address\/\" target=\"_blank\" rel=\"noopener\">click<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Steps to Block IP Addresses with .htaccess file Here in this post i am going to explain how to deny an IP address or how to allow only a particular IP address to access your site This will helps and useful for you to protect your websites from hackers or to block any unwanted visitors.<\/p>\n","protected":false},"author":1,"featured_media":147,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,17,1,9,3,16],"tags":[65,63,66],"class_list":["post-143","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basics","category-control-panel","category-home","category-linux","category-linux-tutorials","category-monitoring-tools","tag-htacces","tag-deny","tag-ip-address"],"_links":{"self":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts\/143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":0,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/posts\/143\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/media\/147"}],"wp:attachment":[{"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tiruppurwebhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}