کد PHP:
RewriteCond %{HTTPS} !=on
RewriteRule 
https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]