强制跳转HTTPS

Apache

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

Nginx

if ($server_port = 80) {
rewrite ^(.*)$ https://$host$1 permanent;
}
Author

Linus Xiong

Posted on

2018-04-05

Updated on

2019-04-04

Licensed under

Comments