{"id":12485,"date":"2021-11-23T12:45:25","date_gmt":"2021-11-23T12:45:25","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=12485"},"modified":"2022-02-15T10:27:18","modified_gmt":"2022-02-15T10:27:18","slug":"block-country-traffic-cpanel","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/","title":{"rendered":"How to Block Country Traffic in cPanel?"},"content":{"rendered":"<p>It is necessary to prevent specific visitors from accessing your website to avoid any conflicts or complications. Regular cPanel&nbsp;users can block the web traffic of a country on their&nbsp;hosting by editing the <em>htaccess<\/em> file.<\/p>\n<h2>To Block Country Traffic<\/h2>\n<p>1. Log in to your <em>cPanel<\/em> account.<\/p>\n<p>2. Edit the&nbsp;<em>.htaccess<\/em> file via the <strong>File Manager<\/strong> tool.<\/p>\n<p>This article shows-&nbsp;<a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-edit-a-htaccess-file-through-the-cpanel-file-manager\/\">How To Edit A .htaccess File Through The cPanel File Manager?<\/a><\/p>\n<p>3. Enter this line at the end of the file:<\/p>\n<pre class=\"lang:default decode:true\">&lt;IfModule mod_geoip.c&gt; \nRewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$ \nRewriteRule ^(.*)$ \u2013 [F,L] \n&lt;\/IfModule&gt;<\/pre>\n<p>The given line has used the&nbsp;<strong>US<\/strong>, which is the country code for the United States of America. It will<\/p>\n<p>You can refer to this link&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/ISO_3166-1_alpha-2#JO\" target=\"_blank\" rel=\"nofollow noopener\">ISO 3166-1 alpha-2<\/a> to find the country codes you are looking for.<\/p>\n<p>4. Click on&nbsp;<strong>Save Changes<\/strong> and <strong>Close<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14131\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png\" alt=\"\" width=\"1919\" height=\"658\"><\/p>\n<p>With it, the country traffic you choose to block will be screened by cPanel. It means the server will reject any access request from the country you blocked and return a <em>403 forbidden error<\/em> for the users.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is necessary to prevent specific visitors from accessing your website to avoid any conflicts or complications. Regular cPanel&nbsp;users can block the web traffic of a country on their&nbsp;hosting by editing the htaccess file. To Block Country Traffic 1. Log in to your cPanel account. 2. Edit the&nbsp;.htaccess file via the File Manager tool. This [&hellip;]<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,41],"tags":[2725,2726,2503,50,533],"class_list":["post-12485","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-cpanel-faq","category-howtos","tag-block-country-traffic","tag-block-country-traffic-cpanel","tag-block-traffic","tag-cpanel-hosting-2","tag-website-traffic"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Block Country Traffic in cPanel? - Web Hosting FAQs by MilesWeb<\/title>\n<meta name=\"description\" content=\"This article will show cPanel users how to block the traffic from a country to the hosting by editing the .htaccess file using the File Manager tool.\" \/>\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.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Block Country Traffic in cPanel? - Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"og:description\" content=\"This article will show cPanel users how to block the traffic from a country to the hosting by editing the .htaccess file using the File Manager tool.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-23T12:45:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-15T10:27:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png\" \/>\n<meta name=\"author\" content=\"Prasad Khartadkar\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prasad Khartadkar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/\",\"name\":\"How to Block Country Traffic in cPanel? - Web Hosting FAQs by MilesWeb\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png\",\"datePublished\":\"2021-11-23T12:45:25+00:00\",\"dateModified\":\"2022-02-15T10:27:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/c9138a9488172a8d0aa2d4f40878d83e\"},\"description\":\"This article will show cPanel users how to block the traffic from a country to the hosting by editing the .htaccess file using the File Manager tool.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#primaryimage\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png\",\"contentUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png\",\"width\":1919,\"height\":658},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Block Country Traffic in cPanel?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/c9138a9488172a8d0aa2d4f40878d83e\",\"name\":\"Prasad Khartadkar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fafb102a39aa8f8d38a11f3e2dcfa746?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fafb102a39aa8f8d38a11f3e2dcfa746?s=96&d=blank&r=g\",\"caption\":\"Prasad Khartadkar\"},\"description\":\"Prasad is a business grad specialized in Marketing. He has garnered experience as a technical content writer and a digital marketer that he brings out in his work. He likes reading classics and travel in his free time.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/prasad-khartadkar\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Block Country Traffic in cPanel? - Web Hosting FAQs by MilesWeb","description":"This article will show cPanel users how to block the traffic from a country to the hosting by editing the .htaccess file using the File Manager tool.","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.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/","og_locale":"en_GB","og_type":"article","og_title":"How to Block Country Traffic in cPanel? - Web Hosting FAQs by MilesWeb","og_description":"This article will show cPanel users how to block the traffic from a country to the hosting by editing the .htaccess file using the File Manager tool.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2021-11-23T12:45:25+00:00","article_modified_time":"2022-02-15T10:27:18+00:00","og_image":[{"url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png","type":"","width":"","height":""}],"author":"Prasad Khartadkar","twitter_misc":{"Written by":"Prasad Khartadkar","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/","name":"How to Block Country Traffic in cPanel? - Web Hosting FAQs by MilesWeb","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#primaryimage"},"image":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#primaryimage"},"thumbnailUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png","datePublished":"2021-11-23T12:45:25+00:00","dateModified":"2022-02-15T10:27:18+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/c9138a9488172a8d0aa2d4f40878d83e"},"description":"This article will show cPanel users how to block the traffic from a country to the hosting by editing the .htaccess file using the File Manager tool.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#primaryimage","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png","contentUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2021\/11\/cp_block_country_traffic.png","width":1919,"height":658},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/block-country-traffic-cpanel\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to Block Country Traffic in cPanel?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/c9138a9488172a8d0aa2d4f40878d83e","name":"Prasad Khartadkar","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fafb102a39aa8f8d38a11f3e2dcfa746?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fafb102a39aa8f8d38a11f3e2dcfa746?s=96&d=blank&r=g","caption":"Prasad Khartadkar"},"description":"Prasad is a business grad specialized in Marketing. He has garnered experience as a technical content writer and a digital marketer that he brings out in his work. He likes reading classics and travel in his free time.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/prasad-khartadkar\/"}]}},"views":349,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/12485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=12485"}],"version-history":[{"count":2,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/12485\/revisions"}],"predecessor-version":[{"id":13406,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/12485\/revisions\/13406"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=12485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=12485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=12485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}