RewriteEngine on 
RewriteBase / 
RewriteCond %{SERVER_PORT} !^443$ 
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

点击下载 htaccess.zip

写法2:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]