Today we will learn how to redirect websites in HTTP to HTTPS.
When you add an SSL certificate to your website, your web server will also continue to serve the HTTP version of your web pages. So you have to redirect HTTP to HTTPS and implement SSL on your website. Here is how to redirect your HTTP to HTTPS using the .htaccess file under public_html by opening CPanel.
Table of Contents
How to Redirect HTTP to HTTPS Using a .htaccess File
Here is how to redirect HTTP to HTTPS in Cpanel using a .htaccess file. Follow the steps given below and secure your website.
Step 1: Open your Cpanel
Step 2: Create .htaccess File
open your Cpanel then click public_html and now check the .htaccess file where. you don’t see their file so create a new file.
Note:- Create a new file only if there is no .htaccess file
Step 3: Open .htaccess File and Paste some code
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.Yourwebsitename.com/$1 [R,L]
Paste the following code in the .htaccess file and save the file by entering the URL of your website.