RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Make sure that you replace www.example.com with your domain name.If for some reason you need your site to appear only on http then you can use the following instead:
RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]