{"id":34424,"date":"2021-10-20T15:06:49","date_gmt":"2021-10-20T15:06:49","guid":{"rendered":"https:\/\/www.hostduplex.com\/kb\/?post_type=ht_kb&#038;p=34424"},"modified":"2021-11-01T21:38:01","modified_gmt":"2021-11-01T21:38:01","slug":"how-to-force-https-using-htaccess","status":"publish","type":"ht_kb","link":"https:\/\/www.hostduplex.com\/kb\/article\/how-to-force-https-using-htaccess\/","title":{"rendered":"How to Force HTTPS using .htaccess"},"content":{"rendered":"\n<p>After installing an SSL certificate, your website is available over HTTP and HTTPS, but it\u2019s recommended to use only the latter because it encrypts and secures your website\u2019s data. This article will show you how to force HTTPS using your File Manager.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Forcing HTTPS on All Traffic<\/h3>\n\n\n\n<p>You can activate the feature to force HTTPS on all incoming traffic by following these steps:<\/p>\n\n\n\n<p>1. Log in to your cPanel account<\/p>\n\n\n\n<p>2. Go to the File Manager. You can scroll down to the Files section or use the search bar to find it<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"429\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-1024x429.jpg\" alt=\"\" class=\"wp-image-34554\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-1024x429.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-300x126.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-768x322.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-50x21.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-1536x644.jpg 1536w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-60x25.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1-100x42.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/file-manager-1.jpg 1978w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>3. On the public_html folder, look for the .htacces file. Right click on it and select Edit<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"754\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-1024x754.jpg\" alt=\"\" class=\"wp-image-34426\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-1024x754.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-300x221.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-768x566.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-50x37.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-60x44.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3-100x74.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/2-3.jpg 1533w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>4. This window will show up. Just click on Edit<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"471\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1024x471.jpg\" alt=\"\" class=\"wp-image-34560\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1024x471.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-300x138.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-768x353.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-50x23.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-1536x706.jpg 1536w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-60x28.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8-100x46.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/ut8.jpg 1799w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>5. Add the following code at the top of the file <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On \nRewriteCond %{HTTPS} off \nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"539\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2-1024x539.jpg\" alt=\"\" class=\"wp-image-34428\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2-1024x539.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2-300x158.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2-768x404.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2-50x26.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2-60x32.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2-100x53.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/4-2.jpg 1135w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>6. Click the Save Changes button on the top right. You will see a Success message, you can now close the editor<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"451\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-1024x451.jpg\" alt=\"\" class=\"wp-image-34561\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-1024x451.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-300x132.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-768x339.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-50x22.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-1536x677.jpg 1536w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-60x26.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats-100x44.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/11\/cats.jpg 1794w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Forcing HTTPS on a Specific Domain<\/h3>\n\n\n\n<p>You can also force HTTPS on one single domain. If that&#8217;s the case, follow the steps above but use the following code on step 5.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On \nRewriteCond %{HTTP_HOST} ^yourdomain1.com [NC] \nRewriteCond %{HTTPS} off \nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]<\/pre>\n\n\n\n<p>It should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"411\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3-1024x411.jpg\" alt=\"\" class=\"wp-image-34433\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3-1024x411.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3-300x120.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3-768x308.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3-50x20.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3-60x24.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3-100x40.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/5-3.jpg 1328w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">Make sure to replace&nbsp;<strong>yourdomain1.com&nbsp;<\/strong>with the actual domain you\u2019re trying to force HTTPS on.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Forcing HTTPS on a Specific Folder<\/h3>\n\n\n\n<p>The&nbsp;.htaccess&nbsp;file can also be used to force HTTPS on specific folders. However, the file should be placed in the folder that will have the HTTPS connection. Follow the steps above and replace the code on the step 5 with the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On \nRewriteCond %{HTTPS} off \nRewriteRule ^(folder1|folder2|folder3) https:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]<\/pre>\n\n\n\n<p> It should look like this: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"562\" src=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1-1024x562.jpg\" alt=\"\" class=\"wp-image-34430\" srcset=\"https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1-1024x562.jpg 1024w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1-300x165.jpg 300w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1-768x421.jpg 768w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1-50x27.jpg 50w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1-60x33.jpg 60w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1-100x55.jpg 100w, https:\/\/www.hostduplex.com\/kb\/wp-content\/uploads\/2021\/10\/6-1.jpg 1218w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-background has-purple-background-color has-purple-color is-style-default\"\/>\n\n\n\n<p>If you are a Host Duplex customer and still have questions, please open a ticket in the&nbsp;<a href=\"https:\/\/secure.hostduplex.com\/clientarea.php\" target=\"_blank\" rel=\"noopener\">Host Duplex client portal.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After installing an SSL certificate, your website is available over HTTP and HTTPS, but it\u2019s recommended to use only the latter because it encrypts and secures your website\u2019s data. This article will show you how to force HTTPS using your File Manager. Forcing HTTPS on All Traffic You can activate&#8230;<\/p>\n","protected":false},"author":2,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"ht-kb-category":[20,3,131],"ht-kb-tag":[23,185,187,188,184],"class_list":["post-34424","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-cpanel","ht_kb_category-account-management","ht_kb_category-ssl","ht_kb_tag-cpanel","ht_kb_tag-force","ht_kb_tag-htaccess","ht_kb_tag-http","ht_kb_tag-https"],"_links":{"self":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/comments?post=34424"}],"version-history":[{"count":3,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34424\/revisions"}],"predecessor-version":[{"id":34562,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb\/34424\/revisions\/34562"}],"wp:attachment":[{"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/media?parent=34424"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=34424"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.hostduplex.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=34424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}