{"id":500,"date":"2024-05-15T15:16:04","date_gmt":"2024-05-15T15:16:04","guid":{"rendered":"https:\/\/www.vpsjungle.in\/tutorials\/?p=500"},"modified":"2024-05-15T16:45:27","modified_gmt":"2024-05-15T16:45:27","slug":"how-to-redirect-http-to-https","status":"publish","type":"post","link":"https:\/\/www.vpsjungle.in\/tutorials\/how-to-redirect-http-to-https\/","title":{"rendered":"How to redirect HTTP to HTTPS Using .htaccess"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Chrome and Firefox have started showing insecure warnings on sites without SSL certificates. Without SSL, your website will show insecure to the visitors. Therefore, using an SSL-encrypted connection for safety, accessibility or PCI compliance reasons is necessary. It becomes very important to redirect from HTTP to HTTPS.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn-media-1.freecodecamp.org\/images\/0*wUTFJrRSM2vh1H7v.jpg\" alt=\"0*wUTFJrRSM2vh1H7v\"\/><\/figure>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#what-is-ssl\">What is SSL?<\/a><\/li><li><a href=\"#editing-htaccess-in-c-panel-file-manager\">Editing .htaccess in cPanel File Manager<\/a><\/li><li><a href=\"#redirecting-http-to-https\">Redirecting HTTP to HTTPS<\/a><ul><li><a href=\"#1-redirect-all-web-traffic\">1. Redirect All Web Traffic<\/a><\/li><li><a href=\"#2-redirect-only-a-specific-domain\">2. Redirect Only a Specific Domain<\/a><\/li><li><a href=\"#3-redirect-only-a-specific-folder\">3. Redirect Only a Specific Folder<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-ssl\">What is SSL?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">SSL (Secure Sockets Layer) is a standard security protocol for establishing encrypted links between a web server and a browser in an online communication.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The usage of SSL technology ensures that all data transmitted between the web server and browser remains encrypted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An <strong>SSL certificate<\/strong> is necessary to create SSL connection. You would need to give all details about the identity of your website and your company as and when you choose to activate SSL on your web server. Following this, two cryptographic keys are created\u200a\u2014\u200aa Private Key and a Public Key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to force your web traffic to use HTTPS, edit the codes in the <strong>.htaccess file.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before we move onto redirecting HTTP to HTTPS, here\u2019s how you can edit .htaccess file. If you already know skip to Redirection steps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"editing-htaccess-file\">Editing .htaccess File<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are instructions\/directives in the .htaccess file that tell the server how to act in certain scenarios and directly affects how your website functions. Common directives in .htaccess file:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Redirects<\/li>\n\n\n\n<li>Rewriting URLs<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ways to edit an .htaccess file:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Edit the file on your computer and upload it to the server using FTP.<\/li>\n\n\n\n<li>Use \u201cEdit\u201d mode in FTP program that allows you to edit a file remotely.<\/li>\n\n\n\n<li>Use a text editor and SSH to edit the file.<\/li>\n\n\n\n<li>Use the File Manager in <strong>cPanel<\/strong> to edit the file.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"editing-htaccess-in-c-panel-file-manager\">Editing .htaccess in cPanel File Manager<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note: <\/strong>Backup your website in case something goes wrong.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.vpsjungle.in\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.vpsjungle.in\/\" rel=\"noreferrer noopener nofollow\">Login to cPanel<\/a><\/li>\n\n\n\n<li>Files > File Manager > Document Root for:<\/li>\n\n\n\n<li>Now select the domain name you want to access<\/li>\n\n\n\n<li>Check \u201cShow Hidden Files (dotfiles)\u201d<\/li>\n\n\n\n<li>Click \u201cGo\u201d<\/li>\n\n\n\n<li>After a new tab or window opens, look for the .htaccess file.<\/li>\n\n\n\n<li>Right click on the .htaccess file and click on \u201cCode Edit\u201d on the menu.<\/li>\n\n\n\n<li>A dialogue box may pop up asking about encoding. Click \u201cEdit\u201d button to continue.<\/li>\n\n\n\n<li>Edit the file<\/li>\n\n\n\n<li>\u201cSave Changes\u201d when done.<\/li>\n\n\n\n<li>Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.<\/li>\n\n\n\n<li>Once you are done, click \u201cClose\u201d to close the window.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"redirecting-http-to-https\">Redirecting HTTP to HTTPS<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"240\" src=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/0-P6EKtlMMzyIXNRMw-1.png\" alt=\"\" class=\"wp-image-505\" srcset=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/0-P6EKtlMMzyIXNRMw-1.png 670w, https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/0-P6EKtlMMzyIXNRMw-1-300x107.png 300w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1-redirect-all-web-traffic\">1. Redirect All Web Traffic<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you have existing code in your .htaccess, add the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"596\" height=\"97\" src=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-4.png\" alt=\"\" class=\"wp-image-501\" style=\"width:600px;height:auto\" srcset=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-4.png 596w, https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-4-300x49.png 300w\" sizes=\"auto, (max-width: 596px) 100vw, 596px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2-redirect-only-a-specific-domain\">2. Redirect Only a Specific Domain<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">For redirecting a specific domain to use HTTPS, add the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"677\" height=\"110\" src=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-5.png\" alt=\"\" class=\"wp-image-502\" style=\"width:610px;height:auto\" srcset=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-5.png 677w, https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-5-300x49.png 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-redirect-only-a-specific-folder\">3. Redirect Only a Specific Folder<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Redirecting to HTTPS on a specific folder, add the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"615\" height=\"112\" src=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-6.png\" alt=\"\" class=\"wp-image-503\" style=\"width:614px;height:auto\" srcset=\"https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-6.png 615w, https:\/\/www.vpsjungle.in\/tutorials\/wp-content\/uploads\/2024\/05\/image-6-300x55.png 300w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Note: Replace <em><code>\u201cyourdomain\u201d<\/code><\/em> with your actual domain name wherever required. Also, in case of the folder, replace<em> <code>\/folder<\/code><\/em> with the actual folder name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Congratulations! you have successfully edited your <strong>.htaccess file<\/strong> and redirected all HTTP traffic to HTTPS, the safe version of your website. Depending on the platform where you developed your website, there could be alternative methods to enable this feature. For example, you can configure your WordPress or PrestaShop site to work with HTTPS using plugins.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chrome and Firefox have started showing insecure warnings on sites without SSL certificates. Without SSL, your website will show insecure to the visitors. Therefore, using an SSL-encrypted connection for safety, accessibility or PCI compliance reasons is necessary. It becomes very important to redirect from HTTP to HTTPS. What is SSL? SSL (Secure Sockets Layer) is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":508,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-500","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-control-panel"],"_links":{"self":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts\/500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/comments?post=500"}],"version-history":[{"count":5,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts\/500\/revisions"}],"predecessor-version":[{"id":513,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/posts\/500\/revisions\/513"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/media\/508"}],"wp:attachment":[{"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/media?parent=500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/categories?post=500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vpsjungle.in\/tutorials\/wp-json\/wp\/v2\/tags?post=500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}