The below code when added to an .htaccess file will automatically redirect any traffic destined for http: to https:
Note: Please change (www.yourdomain.com) with your own domain name and also keep in mind which version of it is correct version of your website either https://www.yourdomain.com/ or https://yourdomain.com/ ..
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
Or You can do this by following code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>
Note: Please change (www.yourdomain.com) with your own domain name and also keep in mind which version of it is correct version of your website either https://www.yourdomain.com/ or https://yourdomain.com/ ..