{"id":1123,"date":"2019-01-08T11:03:51","date_gmt":"2019-01-08T11:03:51","guid":{"rendered":"https:\/\/cloudhost.com.ng\/blog\/?p=1123"},"modified":"2019-01-08T11:03:51","modified_gmt":"2019-01-08T11:03:51","slug":"how-to-force-https-using-the-htaccess-file","status":"publish","type":"post","link":"https:\/\/cloudhost.com.ng\/blog\/how-to-force-https-using-the-htaccess-file\/","title":{"rendered":"How to Force https Using the .htaccess File"},"content":{"rendered":"<p>Your website&#8217;s visitors should be able to access your site using an SSL-encrypted connection for added security, accessibility, or PCI compliance (Payment Card Industry).<\/p>\n<p><a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/how-to-force-https-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1124\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/how-to-force-https-01.png\" alt=\"\" width=\"900\" height=\"300\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/how-to-force-https-01.png 900w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/how-to-force-https-01-300x100.png 300w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/how-to-force-https-01-768x256.png 768w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/how-to-force-https-01-640x213.png 640w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/how-to-force-https-01-624x208.png 624w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<p>The following are easy steps to force your website to redirect from http to https: The first step is to contact your hosting company to ensure that https is available.<\/p>\n<p><strong>Edit .htaccess File<\/strong><\/p>\n<p>Ways to edit an .htaccess file:<\/p>\n<ul>\n<li>Edit the file on your computer and upload it to the server using FTP.<\/li>\n<li>Use \u201cEdit\u201d mode in FTP program that allows you to edit a file remotely.<\/li>\n<li>Use a text editor and SSH (Secure Shell) to edit the file.<\/li>\n<li>Use the File Manager in cPanel to edit the file. (The one used in this article).<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Editing .htaccess in cPanel File Manager<\/strong><\/p>\n<ol>\n<li>Login to cPanel.<\/li>\n<li>Files &gt; File Manager &gt; Document Root of your website.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-file-manager.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1125\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-file-manager.png\" alt=\"\" width=\"712\" height=\"308\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-file-manager.png 712w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-file-manager-300x130.png 300w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-file-manager-640x277.png 640w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-file-manager-624x270.png 624w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/a><\/p>\n<ol start=\"3\">\n<li>Now select the domain name you want to access (For primary cPanel domains, the folder is usually \u2018public_html\u2019.)<\/li>\n<\/ol>\n<p><a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-public.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1126\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-public.png\" alt=\"\" width=\"523\" height=\"203\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-public.png 523w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-public-300x116.png 300w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/a><\/p>\n<ol start=\"4\">\n<li>Click\u00a0&#8216;Settings in the top-right corner and tick\u00a0&#8216;Show hidden files (dot files).<\/li>\n<\/ol>\n<p><a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1127\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-3.png\" alt=\"\" width=\"608\" height=\"347\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-3.png 608w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-3-300x171.png 300w\" sizes=\"(max-width: 608px) 100vw, 608px\" \/><\/a><\/p>\n<p>If the file did not appear, feel free to create it by clicking\u00a0&#8216;+File&#8217;. Make sure to name the file\u00a0&#8216;.htaccess&#8217;, (starting with the dot).<\/p>\n<p><a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1128\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture.png\" alt=\"\" width=\"400\" height=\"124\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture.png 400w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-300x93.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<ol start=\"5\">\n<li>To open the file, right-click it, then click\u00a0&#8216;Edit&#8217;. In the next pop-up window, click\u00a0&#8216;Edit&#8217;as well.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1129\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-4.png\" alt=\"\" width=\"456\" height=\"243\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-4.png 456w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-4-300x160.png 300w\" sizes=\"(max-width: 456px) 100vw, 456px\" \/><\/a><\/p>\n<ol start=\"6\">\n<li>Edit the file.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1130\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-5.png\" alt=\"\" width=\"561\" height=\"354\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-5.png 561w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-5-300x189.png 300w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><\/a><\/p>\n<p>7. \u201cSave Changes\u201d when done.<\/p>\n<p><strong>\u00a0<a href=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1131\" src=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-6.png\" alt=\"\" width=\"417\" height=\"52\" srcset=\"https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-6.png 417w, https:\/\/cloudhost.com.ng\/blog\/wp-content\/uploads\/2019\/01\/Capture-6-300x37.png 300w\" sizes=\"(max-width: 417px) 100vw, 417px\" \/><\/a><\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Redirecting HTTP to HTTPS<\/strong><\/p>\n<p><strong>Redirect all web traffic to https<\/strong>: Edit some set of codes in your .htaccess root file to the ones provided below:<\/p>\n<p>To force all web traffic to use HTTPS, insert the following lines of code in the .htaccess file in your website\u2019s root folder. (Note: If you have existing code in your .htaccess, add this above where there are already rules with a similar starting prefix.<\/p>\n<p>&nbsp;<\/p>\n<p>RewriteEngine On<\/p>\n<p>RewriteCond %{HTTPS} !on<\/p>\n<p>RewriteCond %{REQUEST_URI} !^\/[0-9]+\\..+\\.cpaneldcv$<\/p>\n<p>RewriteCond %{REQUEST_URI} !^\/\\.well-known\/pki-validation\/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$<\/p>\n<p>RewriteRule \u00a0^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Redirect only specified domain:<\/strong><\/p>\n<p>To force a specific domain to use HTTPS, use the following lines of code in the .htaccess file in your website\u2019s root folder:<\/p>\n<p>RewriteCond %{REQUEST_URI} !^\/[0-9]+\\..+\\.cpaneldcv$<\/p>\n<p>RewriteCond %{REQUEST_URI} !^\/\\.well-known\/pki-validation\/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$<\/p>\n<p>RewriteEngine On<\/p>\n<p>RewriteCond %{HTTP_HOST} ^example\\.com [NC]<\/p>\n<p>RewriteCond %{SERVER_PORT} 80<\/p>\n<p>RewriteRule ^(.*)$ https:\/\/www.example.com\/$1 [R=301,L]<\/p>\n<p>If the code above doesn\u2019t work, try removing the first two lines. E.g<\/p>\n<p>RewriteEngine On<\/p>\n<p>RewriteCond %{HTTP_HOST} ^example\\.com [NC]<\/p>\n<p>RewriteCond %{SERVER_PORT} 80<\/p>\n<p>RewriteRule ^(.*)$ https:\/\/www.example.com\/$1 [R=301,L]<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Redirect specified Folder<\/strong>:<\/p>\n<p>If you want to force SSL on a specific folder, insert the code below into an .htaccess file placed in that specific folder:<\/p>\n<p>RewriteCond %{REQUEST_URI} !^\/[0-9]+\\..+\\.cpaneldcv$<\/p>\n<p>RewriteCond %{REQUEST_URI} !^\/\\.well-known\/pki-validation\/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$<\/p>\n<p>RewriteEngine On<\/p>\n<p>RewriteCond %{SERVER_PORT} 80<\/p>\n<p>RewriteCond %{REQUEST_URI} folder<\/p>\n<p>RewriteRule ^(.*)$ https:\/\/www.example.com\/folder\/$1 [R=301,L]<\/p>\n<p>Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com\/folder with your actual domain name and folder you want to force the SSL on.<\/p>\n<p>For further assistance feel free to contact <a href=\"mailto:support@cloudhost.com.ng\">CloudHost Support<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your website&#8217;s visitors should be able to access your site using an SSL-encrypted connection for added security, accessibility, or PCI compliance (Payment Card Industry). The following are easy steps to force your website to redirect from http to https: The first step is to contact your hosting company to ensure that https is available. Edit [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":1133,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6,7,1,18],"tags":[26,24,25],"yst_prominent_words":[],"class_list":["post-1123","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloudhost-support","category-cpanel","category-cpanel-file-manager","category-uncategorized","category-web-hosting","tag-htaccess","tag-http","tag-https"],"_links":{"self":[{"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/posts\/1123"}],"collection":[{"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/comments?post=1123"}],"version-history":[{"count":5,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":1138,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/posts\/1123\/revisions\/1138"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/media\/1133"}],"wp:attachment":[{"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/media?parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/categories?post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/tags?post=1123"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/cloudhost.com.ng\/blog\/wp-json\/wp\/v2\/yst_prominent_words?post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}