{"id":155,"date":"2018-08-09T22:04:51","date_gmt":"2018-08-09T12:04:51","guid":{"rendered":"https:\/\/typicalhosting.com.au\/blog\/?p=155"},"modified":"2019-12-23T20:55:43","modified_gmt":"2019-12-23T10:55:43","slug":"force-https-htaccess","status":"publish","type":"post","link":"https:\/\/typicalhosting.com.au\/blog\/force-https-htaccess\/","title":{"rendered":"How to Force HTTPS Using the .htaccess"},"content":{"rendered":"<h2 style=\"text-align: center;\">Force HTTPS Using .htaccess<\/h2>\n<h2 style=\"text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-198 size-full\" title=\"Force HTTPS\" src=\"https:\/\/typicalhosting.com.au\/blog\/wp-content\/uploads\/2018\/08\/https-green-padlock-650x282.png\" alt=\"Force HTTPS\" width=\"650\" height=\"282\" srcset=\"https:\/\/typicalhosting.com.au\/blog\/wp-content\/uploads\/2018\/08\/https-green-padlock-650x282.png 650w, https:\/\/typicalhosting.com.au\/blog\/wp-content\/uploads\/2018\/08\/https-green-padlock-650x282-300x130.png 300w, https:\/\/typicalhosting.com.au\/blog\/wp-content\/uploads\/2018\/08\/https-green-padlock-650x282-640x278.png 640w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/h2>\n<p>If you have Purchased an SSL Certificate and have setup your SSL within cPanel then you can use this method to Force Visitors to use SSL.<\/p>\n<p>If you have not yet purchased an SSL Certificate you can purchase one &#8220;<a href=\"https:\/\/typicalhosting.com.au\/am\/cart.php?gid=4\">Here<\/a>&#8221;<\/p>\n<p>We have also created a guide on how to setup your SSL Certificate after your purchase. You can follow our guide &#8220;<a href=\"https:\/\/typicalhosting.com.au\/blog\/setup-ssl-certificate\/\">Here<\/a>&#8221;<\/p>\n<p>Also Most importantly after you have purchased and setup your SSL you will need to Install Your SSL Certificate into cPanel. You can find our guide &#8220;<a href=\"https:\/\/typicalhosting.com.au\/blog\/installing-ssl-certificate\/\">Here<\/a>&#8221;<\/p>\n<h2>Force HTTPS Using .htaccess<\/h2>\n<p>after you have completed the above tutorials or if you have already installed your SSL Certificate then please continue below.<\/p>\n<p>Forcing visitors to use your SSL can be Achieved through your .htaccess file using mod_rewrite.<\/p>\n<h2>Where To Locate Your .htaccess File<\/h2>\n<p>your .htaccess file is found within your public_html folder within your hosting account. it is usually always located in the root directory of your website.<br \/>\nThe picture below is taken from FileZilla <a href=\"https:\/\/typicalhosting.com.au\/blog\/whats-an-ftp\/\">FTP<\/a>.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-202\" src=\"https:\/\/typicalhosting.com.au\/blog\/wp-content\/uploads\/2018\/08\/htaccess4-1.png\" alt=\"htaccess\" width=\"485\" height=\"271\" srcset=\"https:\/\/typicalhosting.com.au\/blog\/wp-content\/uploads\/2018\/08\/htaccess4-1.png 485w, https:\/\/typicalhosting.com.au\/blog\/wp-content\/uploads\/2018\/08\/htaccess4-1-300x168.png 300w\" sizes=\"(max-width: 485px) 100vw, 485px\" \/><\/p>\n<h2>Redirecting All Web Traffic with .htaccess<\/h2>\n<p>To force web traffic to use HTTPS you will need to insert the following code into your .htaccess file within your websites root directory.<\/p>\n<div class=\"alert alert-warning\" role=\"alert\">\n<p><b>PLEASE NOTE: <\/b>If you have any existing code in your .htaccess file you will need to add this &#8220;Above&#8221; your other .htaccess rules.<\/p>\n<\/div>\n<pre class=\"code_block\">RewriteEngine On\r\nRewriteCond %{HTTPS} !on\r\nRewriteCond %{REQUEST_URI} !^\/[0-9]+\\..+\\.cpaneldcv$\r\nRewriteCond %{REQUEST_URI} !^\/\\.well-known\/pki-validation\/[A-F0-9]{32}\\.txt(?:\\ Comodo\\ DCV)?$\r\nRewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI}\r\n<\/pre>\n<p>Now you have saved the file and uploaded back into your web root directory you will be able to go your website &#8220;e.g https:\/\/www.yourwebsite.com&#8221; and you should be able to see a &#8220;Green Padlock&#8221; in your browsers address bar.<\/p>\n<p>If you have run into a privacy issue within your browser there could be a few issues and you will need to go back and double check that you have <a href=\"https:\/\/typicalhosting.com.au\/blog\/installing-ssl-certificate\/\">Installed your SSL Certificate<\/a> correctly.<\/p>\n<p>And Make sure that you have edited and uploaded the .htaccess file after entering the code above.<\/p>\n<p>If all else fails please feel free to contact us via a &#8220;<a href=\"https:\/\/typicalhosting.com.au\/am\/submitticket.php?step=2&amp;deptid=3\">Support ticket&#8221;<\/a>. and we will do our best to assist you with any problems that may occur.<\/p>\n<p>We hope this How-to has helped you. if you think I have missed anything please feel free to leave a comment below<\/p>\n<p>Thanks.<br \/>\nSimon M.<br \/>\nTypical Hosting<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Force HTTPS Using .htaccess If you have Purchased an SSL Certificate and have setup your SSL within cPanel then you can use this method to Force Visitors to use SSL. If you have not yet purchased an SSL Certificate you&hellip; <a href=\"https:\/\/typicalhosting.com.au\/blog\/force-https-htaccess\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":198,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4],"tags":[],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/posts\/155"}],"collection":[{"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/comments?post=155"}],"version-history":[{"count":9,"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions\/207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/media\/198"}],"wp:attachment":[{"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/media?parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/categories?post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/typicalhosting.com.au\/blog\/wp-json\/wp\/v2\/tags?post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}