Chrome and Firefox have started showing insecure warnings on sites without SSL certificates. Without SSL, your website viewer feels insecure. SSL Certificate is very important, so in this tutorial, I will guide you How to force redirect HTTP to HTTPS using .htaccess.

Editing .htaccess in cPanel File Manager
Note: Backup your website in case something goes wrong.

STEP 1: Log in to cPanel


STEP 2: Files > File Manager


STEP 3: Now select the domain name you want to access
STEP 4: Click on setting icon and Check “Show Hidden Files (dotfiles)”


STEP 5: Click “Go”
STEP 6: After a new tab or window opens, look for the .htaccess file.


STEP 7: Right-click on the .htaccess file and click on “Code Edit” on the menu.
STEP 8: A dialogue box may pop up asking about encoding. Click the “Edit” button to continue.
STEP 9: Edit the file and add the line given below.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
</IfModule>

STEP 10: “Save Changes” when done.
STEP 11: Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
STEP 12: Once you are done, click “Close” to close the window.