While visiting a website in Chrome or Firefox browser, sometimes an insecure warning even with a valid SSL certificate. Visitors will see your website as insecure even if a valid SSL certificate is installed but the website still opens with HTTP which is why it is important to redirect the website from HTTP to HTTPS.
What is SSL?
SSL (Secure Sockets Layer) is a standard security protocol used in internet communication to establish encrypted communications between a web server and a browser. SSL technology ensures that all data transmitted between the web server and browser is encrypted.
To establish an SSL connection, an SSL certificate is required. When you choose to activate SSL on your web server, you must provide all information about the identity of your website and your company.
To redirect your Web traffic from HTTP to HTTPS you have to edit the code in .htaccess file
There are multiple ways to edit an .htaccess file
- Edit .htaccess file on Local computer and upload it to the server using FTP
- Using text edit or SSH to edit the file
- Using file manager in cPanel file can be edited
Editing .htaccess file in cPanel file manager
Note : Before making any changes in backup file make a copy of .htaccess file or download it on your local machine
1. Login in to cPanel with valid credentials.
2. Under the Files section, click on Flie Manager, or search for File Manager in the search box.
3. Select the domain where you want to make changes in .htaccess file
4. Under Public_html or domain name folder there is .htaccess file
5. If you don’t see any .htaccess file Click on Setting on right hand side
6. A PopUp will appear. Check on Show Hidden files(dotfiles)
7. Right click on .htaccess file and then click on edit Option
8. A popup will appear then click on Edit button
9. New tab will be open .Edit the file and once the following changes are done click on Save changes
10.Test your website to make sure it works correctly.
Redirecting HTTP to HTTPS
1. Redirect All Web traffic to HTTPS
Add the following code in .htaccess file
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
2. Redirect only a specific domain
For redirecting specific domain add the following code
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
(Red highlighted text replace with your actual domain)
3. Redirect Only Specific Folder
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]
(Red highlighted text replace with your actual domain and folder)

