{"id":6152,"date":"2020-11-29T07:11:38","date_gmt":"2020-11-29T07:11:38","guid":{"rendered":"https:\/\/truehost.co.ke\/support\/?post_type=ht_kb&#038;p=6152"},"modified":"2024-06-07T13:03:32","modified_gmt":"2024-06-07T13:03:32","password":"","slug":"how-to-force-https-using-htaccess-file","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/","title":{"rendered":"How to Force HTTPS using .htaccess file"},"content":{"rendered":"\n<p>Website Security is something that no one can debate about because it is paramount unless the site is not legit. So it is important you ensure that your website is always secure by <a href=\"https:\/\/truehost.co.ke\/support\/knowledge-base\/how-to-install-free-ssl-from-lets-encrypt-on-shared-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">INSTALLING AN SSL<\/a><\/p>\n\n\n\n<p>Now, when you install SSL it does not just end there because the website will still operate with a HTTP connection. HTPPS on the other hand ensures encryption and security of your website\u2019s data.<\/p>\n\n\n\n<p>In this guide we will show you how to force HTTPS using the .htaccess file.<\/p>\n\n\n\n<p>Among others <strong>.htaccess<\/strong>\u00a0is responsible for performing the 301 redirects, which permanently redirects an old URL to a new one.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Login to the Cpanel and click <strong>File Manager.<\/strong><\/li><li>Click on the<strong> root <\/strong>folder of your domain. If it is the main domain click the <strong>public_html\u00a0<\/strong>folder and locate <strong>.htaccess<\/strong>. If you can\u2019t locate it, make sure to\u00a0create or unhide it.<\/li><li>Right-click on it and click on edit to open it.<\/li><li>Insert the following lines of code below it:<\/li><\/ol>\n\n\n\n<p><em><strong>RewriteEngine<\/strong> On <\/em><\/p>\n\n\n\n<p><em><strong>RewriteCond<\/strong> %{HTTPS} off <\/em><\/p>\n\n\n\n<p><em><strong>RewriteRule<\/strong> ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/em><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Save<\/strong>\u00a0the changes.<\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Website Security is something that no one can debate about because it is paramount unless the site is not legit. So it is important you ensure that your website is always secure by INSTALLING AN SSL Now, when you install SSL it does not just end there because the website will still operate with a [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[],"doc_tag":[],"class_list":["post-6152","docs","type-docs","status-publish","hentry"],"year_month":"2026-06","word_count":182,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Patrick K","author_nicename":"patrick","author_url":"https:\/\/truehost.com\/support\/author\/patrick\/"},"doc_category_info":[],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Force HTTPS using .htaccess file -<\/title>\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.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Force HTTPS using .htaccess file -\" \/>\n<meta property=\"og:description\" content=\"Website Security is something that no one can debate about because it is paramount unless the site is not legit. So it is important you ensure that your website is always secure by INSTALLING AN SSL Now, when you install SSL it does not just end there because the website will still operate with a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-07T13:03:32+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-force-https-using-htaccess-file\\\/\",\"url\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-force-https-using-htaccess-file\\\/\",\"name\":\"How to Force HTTPS using .htaccess file -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2020-11-29T07:11:38+00:00\",\"dateModified\":\"2024-06-07T13:03:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-force-https-using-htaccess-file\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-force-https-using-htaccess-file\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-force-https-using-htaccess-file\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Force HTTPS using .htaccess file\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Force HTTPS using .htaccess file -","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.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/","og_locale":"en_US","og_type":"article","og_title":"How to Force HTTPS using .htaccess file -","og_description":"Website Security is something that no one can debate about because it is paramount unless the site is not legit. So it is important you ensure that your website is always secure by INSTALLING AN SSL Now, when you install SSL it does not just end there because the website will still operate with a [&hellip;]","og_url":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/","article_modified_time":"2024-06-07T13:03:32+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/","url":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/","name":"How to Force HTTPS using .htaccess file -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2020-11-29T07:11:38+00:00","dateModified":"2024-06-07T13:03:32+00:00","breadcrumb":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-force-https-using-htaccess-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Force HTTPS using .htaccess file"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/6152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=6152"}],"version-history":[{"count":1,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/6152\/revisions"}],"predecessor-version":[{"id":6153,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/6152\/revisions\/6153"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=6152"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=6152"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=6152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}