{"id":1309,"date":"2023-12-13T03:51:39","date_gmt":"2023-12-13T03:51:39","guid":{"rendered":"https:\/\/youstable.com\/blog\/?p=1309"},"modified":"2023-12-13T03:51:40","modified_gmt":"2023-12-13T03:51:40","slug":"block-ip-address-by-country","status":"publish","type":"post","link":"https:\/\/www.youstable.com\/blog\/block-ip-address-by-country\/","title":{"rendered":"How to Allow or Block IP address by Country Using .htaccess"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Privacy invaders, Hackers, Competitors and others attack your site to lower your rank or try to cause inconvenience, so your business does not do well. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">YouStable offers cPanel full version to the registered users so that you can get the most out of the features. cPanel offers a .htaccess file, and you have the power to block IP addresses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>First, we are going to show you, how you can access the cPanel and reach the .htaccess file. <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1<\/strong>: <a href=\"https:\/\/www.youstable.com\/blog\/how-to-login-into-cpanel\/\" target=\"_blank\" rel=\"noreferrer noopener\">Log in to the cPanel<\/a> by adding <strong>(domain.com\/cpanel)<\/strong> and then hit enter. If you have forgotten the credentials, then <strong>open the email client associated with the YouStable account<\/strong> because we send a copy of the credentials to the registered email as well. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2<\/strong>: In the\nsearch bar, type \u201c<strong><em>file manager<\/em><\/strong>\u201d and select the first result. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-2.png\" alt=\"block IP address\" class=\"wp-image-1317\" width=\"693\" height=\"166\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-2.png 1023w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-2-768x184.png 768w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-2-251x60.png 251w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3<\/strong>: Double-click on the \u201c<em><strong>public_html<\/strong><\/em>\u201d and then it will take you one step closer to completing the process. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-3.png\" alt=\"block IP address\" class=\"wp-image-1316\" width=\"695\" height=\"79\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-3.png 1365w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-3-768x88.png 768w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-3-525x60.png 525w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 4<\/strong>: cPanel hides the file, so you have to click on the \u201c<strong>settings<\/strong>\u201d located on the same page at the top, and a pop-up appears on your screen. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step<\/strong> <strong>5:<\/strong> Click on \u201c<strong><em>show hidden files<\/em><\/strong>\u201d and then click on \u201c<strong><em>save<\/em><\/strong>\u201d to complete the process.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-4.png\" alt=\"block IP address\" class=\"wp-image-1315\" width=\"689\" height=\"263\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-4.png 1365w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-4-768x294.png 768w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-4-157x60.png 157w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 6<\/strong>: Now, select the .htaccess file, and right-mouse click to view more options, and click on \u201c<strong><em>edit<\/em><\/strong>\u201d it.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-5.png\" alt=\"block IP address\" class=\"wp-image-1314\" width=\"697\" height=\"196\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-5.png 1053w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-5-768x216.png 768w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-5-213x60.png 213w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 7<\/strong>: The confirmation pop-up shows up, and click on \u201c<strong><em>edit<\/em><\/strong>\u201d to proceed. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-6.png\" alt=\"block IP address\" class=\"wp-image-1313\" width=\"662\" height=\"310\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-6.png 862w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-6-768x361.png 768w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-6-128x60.png 128w\" sizes=\"auto, (max-width: 662px) 100vw, 662px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 8<\/strong>: The .htaccess file is now editable.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-7.png\" alt=\"block IP address\" class=\"wp-image-1312\" width=\"674\" height=\"284\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-7.png 1072w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-7-768x324.png 768w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-7-142x60.png 142w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 9<\/strong>: Go to the IPDENY site to copy the IP address of specific country, and click on \u201c<strong><em>download zone file<\/em><\/strong>\u201d to download a text file, or you can click on \u201c<strong><em>aggregated zone file<\/em><\/strong>\u201d to view the IP address in another window. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-8.png\" alt=\"Allow or Block IP Address 8\" class=\"wp-image-1311\" width=\"668\" height=\"220\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-8.png 921w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-8-768x253.png 768w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-8-182x60.png 182w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 10<\/strong>: Okay, now you have to follow the order from the codes below. <\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-9.png\" alt=\"block IP address\" class=\"wp-image-1310\" width=\"681\" height=\"273\" srcset=\"https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-9.png 744w, https:\/\/www.youstable.com\/blog\/wp-content\/uploads\/2019\/01\/Allow-or-Block-IP-Address-9-150x60.png 150w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>(order allow,\n\ndeny\ndeny from http:\/\/27.116.56.0\/22\n\ndeny from http:\/\/58.147.128.0\/19\n\nallow from all)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The \u201c<strong><em>Deny<\/em><\/strong>\u201d will block the block IP address that you don\u2019t want the traffic to come from it. The rest of the countries can view your site normally, but the mentioned IP address is blocked. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>order allow,\ndeny deny from http:\/\/27.116.56.0\/22\ndeny from http:\/\/58.147.128.0\/19\nallow from all<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Now,<\/strong> if you want to allow specified traffic from selected countries, then you can use the below codes. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>order deny,\nallow deny from all \nallow from 211.35.214.13<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The \u201c<strong><em>allow from IP address<\/em><\/strong>\u201d will allow the specific country only, while the rest of the world is blocked to access the site. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"you-may-also-like\">You may also like<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/youstable.com\/blog\/how-to-change-link-color-in-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>How to change link color in WordPress?<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.youstable.com\/blog\/display-breadcrumb-navigation-links-in-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>How to Display Breadcrumb Navigation Links in WordPress?<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/youstable.com\/blog\/how-to-add-expires-headers\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>How to Add Expires Headers To Your WordPress Website?<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.youstable.com\/blog\/how-to-remove-wordpress-version-number\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>How to Remove WordPress Version Number?<\/strong><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/youstable.com\/blog\/how-to-change-background-color-in-wordpress\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>How to Change Background Color in WordPress<\/strong><\/a><strong>?<\/strong><\/li>\n\n\n\n<li><a href=\"https:\/\/youstable.com\/blog\/how-to-redirect-your-404-pages\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>How to Redirect your 404 pages to the Home Page in WordPress<\/strong><\/a><strong>?<\/strong><\/li>\n\n\n\n<li><a href=\"https:\/\/youstable.com\/blog\/edit-wp-config-php-file\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>How to Edit wp-config.php File in WordPress?<\/strong><\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Privacy invaders, Hackers, Competitors and others attack your site to lower your rank or try to cause inconvenience, so your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9463,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"iawp_total_views":150,"footnotes":""},"categories":[350,1156,2260],"tags":[456,455,460,458,461,457,454,459],"class_list":["post-1309","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase","category-technology","category-kb-web-servers","tag-apache-block-ip","tag-block-ip-htaccess-wordpress","tag-htaccess-allow-from-ip-range","tag-htaccess-allow-from-multiple-ip","tag-htaccess-allow-ip","tag-htaccess-block-ip-range-country","tag-htaccess-block-multiple-ips","tag-rewrite-rule-to-block-ip-address"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/1309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/comments?post=1309"}],"version-history":[{"count":0,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/1309\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media\/9463"}],"wp:attachment":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media?parent=1309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/categories?post=1309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/tags?post=1309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}