{"id":217,"date":"2017-05-07T06:38:21","date_gmt":"2017-05-07T06:38:21","guid":{"rendered":"https:\/\/www.hostingahead.com\/blog\/?p=217"},"modified":"2021-06-19T10:19:49","modified_gmt":"2021-06-19T10:19:49","slug":"how-to-redirect-a-site-to-https-using-htaccess","status":"publish","type":"post","link":"https:\/\/www.hostingahead.com\/blog\/how-to-redirect-a-site-to-https-using-htaccess\/","title":{"rendered":"How to redirect a site to https using htaccess"},"content":{"rendered":"<p>If you want to redirect your domain from HTTP to HTTPS, you can achieve this using<\/p>\n<p>&nbsp;<\/p>\n<p><strong>If you are not using Cloudflare or any proxy server, use the below code in your .htaccess file<\/strong><\/p>\n<p>RewriteCond %{HTTP_HOST} !^www\\.(.*)$ [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/www.%{HTTP_HOST}\/$1 [R=301,L]<br \/>\nRewriteCond %{HTTPS} =off<br \/>\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}\/$1 [R=301,L]<\/p>\n<p><strong>If you are using Cloudflare or any proxy server, use the below code in your .htaccess file<\/strong><br \/>\nRewriteCond %{HTTP_HOST} !^www\\.(.*)$ [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/www.%{HTTP_HOST}\/$1 [R=301,L]<br \/>\nRewriteCond %{HTTP:X-Forwarded-Proto} !https<br \/>\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}\/$1 [R=301,L]<\/p>\n<p>&nbsp;<\/p>\n<p>If you\u00a0 are on WordPress, you will need to install the Cloudflare\u00a0 SSL plugin before activating the files in .htaccess file.<\/p>\n<p>One of the plugins is https:\/\/wordpress.org\/plugins\/cloudflare-flexible-ssl\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to redirect your domain from HTTP to HTTPS, you can achieve this using &nbsp; If you are not using Cloudflare or any proxy server, use the below code in your .htaccess file RewriteCond %{HTTP_HOST} !^www\\.(.*)$ [NC] RewriteRule ^(.*)$ http:\/\/www.%{HTTP_HOST}\/$1 [R=301,L] RewriteCond %{HTTPS} =off RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}\/$1 [R=301,L] If you are using Cloudflare &#8230;<\/p>\n","protected":false},"author":101012,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/217"}],"collection":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/users\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/comments?post=217"}],"version-history":[{"count":3,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/217\/revisions"}],"predecessor-version":[{"id":336,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/217\/revisions\/336"}],"wp:attachment":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/media?parent=217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/categories?post=217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/tags?post=217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}