If you have installed an SSL Certificate on your website and want to redirect your website traffic or a specific domain from ’http’ to ‘https’ using the .htaccess, then you need to add the code given below to your .htaccess file.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Add the following line to your .htaccess if you want to redirect a specific folder from ‘http’ to ‘https.’
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]
Note
You will need to replace example.com with your domain in the code and set the folder name wherever required.