{"id":2415,"date":"2015-07-19T00:29:41","date_gmt":"2015-07-19T00:29:41","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2415"},"modified":"2015-07-19T00:29:41","modified_gmt":"2015-07-19T00:29:41","slug":"force-ssl-in-htaccess-file","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/07\/19\/force-ssl-in-htaccess-file\/","title":{"rendered":"Force SSL in .htaccess file"},"content":{"rendered":"<p>If you have existing code in your .htaccess, add this above where there are already rules with a similar starting prefix.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">RewriteEngine On \nRewriteCond %{SERVER_PORT} 80 \nRewriteRule ^(.*)$ https:\/\/www.yourdomain.com\/$1 &#x5B;R,L]\nBe sure to replace www.yourdomain.com with your actual domain name.\n\n<\/pre>\n<p><!--more--><\/p>\n<p>To force a specific domain to use HTTPS, use the following lines of code in the .htaccess file in your website&#8217;s root folder:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">RewriteEngine On \nRewriteCond %{HTTP_HOST} ^example\\.com &#x5B;NC]\nRewriteCond %{SERVER_PORT} 80 \nRewriteRule ^(.*)$ https:\/\/www.yourdomain.com\/$1 &#x5B;R,L]\nMake sure to replace example\\.com with the domain name you&#039;re trying force to https. Additionally, you need to replace www.yourdomain.com with your actual domain name.\n\n<\/pre>\n<p>If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that specific folder:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">RewriteEngine On \nRewriteCond %{SERVER_PORT} 80 \nRewriteCond %{REQUEST_URI} folder \nRewriteRule ^(.*)$ https:\/\/www.yourdomain.com\/folder\/$1 &#x5B;R,L]\n\n<\/pre>\n<p>Other Resources:<br \/>\n<a href=\"http:\/\/www.askapache.com\/htaccess\/http-https-rewriterule-redirect.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.askapache.com\/htaccess\/http-https-rewriterule-redirect.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have existing code in your .htaccess, add this above where there are already rules with a similar starting prefix. RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https:\/\/www.yourdomain.com\/$1 &#x5B;R,L] Be sure to replace www.yourdomain.com with your actual domain name.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[],"class_list":["post-2415","post","type-post","status-publish","format-standard","hentry","category-sslcertificates"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2415"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2415\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}