网站根目录新建 .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
if ($server_port = 80) { rewrite ^(.*)$ https://$host$1 permanent; }