{"id":1498,"date":"2020-10-30T17:42:56","date_gmt":"2020-10-30T17:42:56","guid":{"rendered":"https:\/\/hostingspell.com\/blog\/?p=1498"},"modified":"2020-11-03T10:28:38","modified_gmt":"2020-11-03T10:28:38","slug":"complete-guide-how-to-set-http-to-https-using-htaccess","status":"publish","type":"post","link":"https:\/\/blog.hostingspell.com\/complete-guide-how-to-set-http-to-https-using-htaccess\/","title":{"rendered":"Complete Guide: How to set HTTP to HTTPS for website, Rule for .htaccess"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">One of the Most requested questions asked by our customers about how they can redirect their website to open in HTTPS instead of HTTP. Well, that&#8217;s the easiest, or we can say copy and paste job!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are Complete Guides for How to Set HTTPS for the website in .htaccess file as well how to create .htaccess file and some useful rules to add in .htaccess. This guide will set to work with all hosting platforms as well as created around cPanel like Control Panel.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Prerequisite:<\/h6>\n\n\n\n<ul class=\"wp-block-list\"><li>Website should point on web hosting server <\/li><li>Valid SSL Certificate already installed<\/li><li>Save all files to local PC before opening it and changing codes inside just for safety<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>If you want to install SSL Certificate for your website using cPanel then follow this guide: <a aria-label=\"How to Install Let's Encrypt SSL in cPanel (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/hostingspell.com\/blog\/how-to-install-lets-encrypt-ssl-certificate-via-cpanel-plugin\/\" target=\"_blank\" class=\"rank-math-link\">How to Install Let&#8217;s Encrypt SSL in cPanel<\/a><\/p><\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\">Scene 1: Load Website in HTTPS  through .htaccess file<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Step 1: <\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">In order to create .htaccess file you need to login to your cPanel. After successfully log into it Search for &#8216;File Manager&#8217; in your cPanel.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Step 2:<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">Inside File Manager on Top-right cornor there&#8217;s &#8216;Settings&#8217;, Open that menu and Tick \u2705 Show Hidden Files option and press &#8216;Go&#8217; button. <\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Step 3:<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">Now head to root directory of your website. Search for file named .htaccess in root directory.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>If there is not .htaccess file then create one and Google about default .htaccess file and paste code whichever you like on internet. <\/p><cite>&#8211; Noobie googler<\/cite><\/blockquote>\n\n\n\n<h6 class=\"wp-block-heading\">Step 4:<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">Open that file, just after syntax like <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On\nRewriteBase \/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Paste below-mentioned code for HTTP to HTTPS <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine On\nRewriteCond %{HTTPS} !=on\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]\nHeader always set Content-Security-Policy \"upgrade-insecure-requests;\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now save file the file. Clear browser cache and type and open http:\/\/ version of your website\u2019s URL. You&#8217;ll see site will automatically loads with https:\/\/ and will show Green SSL Certificate PadLock.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Scene 2: Add www to website with https<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-coblocks-alert\"><p class=\"wp-block-coblocks-alert__title\">This Scene is not suggest for all kind of users, it can throw some error and need some prior knowledge of htaccess ruleset.<\/p><p class=\"wp-block-coblocks-alert__text\">As always save files to your local PC before changing anything to play safe if something goes wrong! <\/p><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Step 1:<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">Follow above mentioned steps from 1 to 3 of Scene 1 as it is described.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Step 2:<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">As mentioned in Step 4 in above Scene 1, just right after syntax like shown below<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine\nOnRewriteBase \/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add following code from below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#For www and https enabled \nRewriteCond %{HTTP_HOST} !^www\\.\nRewriteRule ^(.*)$ https:\/\/www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n\n#Now, rewrite to HTTPS:\nRewriteCond %{HTTPS} off\nRewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And now your site will load with https:\/\/www. Instead of some nonsense you don&#8217;t want! <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the Most requested questions asked by our customers about how they can redirect their website to open in HTTPS instead of HTTP. Well, that&#8217;s the easiest, or we can say copy and paste job! Here are Complete Guides for How to Set HTTPS for the website in .htaccess file as well how to [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":1502,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1498","post","type-post","status-publish","format-standard","has-post-thumbnail","category-general","entry"],"featured_image_src":"https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png","featured_image_src_square":"https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png","author_info":{"display_name":"Dhruv Joshi","author_link":"https:\/\/blog.hostingspell.com\/author\/dhruval\/"},"uagb_featured_image_src":{"full":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png",1920,1080,false],"thumbnail":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-150x150.png",150,150,true],"medium":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-300x169.png",300,169,true],"medium_large":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-768x432.png",768,432,true],"large":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-1024x576.png",1024,576,true],"1536x1536":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-1536x864.png",1536,864,true],"2048x2048":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png",1920,1080,false],"single-featured-image":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-1200x385.png",1200,385,true],"blog-featured-image":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-680x290.png",680,290,true],"home-featured":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000-380x570.png",380,570,true],"ab-block-post-grid-landscape":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png",600,338,false],"ab-block-post-grid-square":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png",600,338,false],"author-pro-image":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png",360,203,false],"gb-block-post-grid-landscape":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png",600,338,false],"gb-block-post-grid-square":["https:\/\/blog.hostingspell.com\/wp-content\/uploads\/2020\/10\/0001-12499348700_20201030_222404_0000.png",600,338,false]},"uagb_author_info":{"display_name":"Dhruv Joshi","author_link":"https:\/\/blog.hostingspell.com\/author\/dhruval\/"},"uagb_comment_info":0,"uagb_excerpt":"One of the Most requested questions asked by our customers about how they can redirect their website to open in HTTPS instead of HTTP. Well, that&#8217;s the easiest, or we can say copy and paste job! Here are Complete Guides for How to Set HTTPS for the website in .htaccess file as well how to&hellip;","_links":{"self":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/posts\/1498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/comments?post=1498"}],"version-history":[{"count":0,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/posts\/1498\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/media\/1502"}],"wp:attachment":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/media?parent=1498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/categories?post=1498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/tags?post=1498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}