【发布时间】:2016-04-27 19:17:27
【问题描述】:
按照我的配置文件:
server {
listen [::]:443 ipv6only=off ssl;
server_name www.example.com;
// ssl stuff
return 301 https://example.com$request_uri;
}
server {
listen [::]:80 ipv6only=off;
return 301 https://example.com$request_uri;
}
server {
listen [::]:443 ssl;
server_name example.com;
// php and ssl stuff
}
我不明白为什么http://www.example.com 会重定向到https://www.example.com,然后再重定向到https://example.com。如何从http://www.example.com直接重定向到https://example.com?
【问题讨论】:
-
您启用了 HSTS 吗?如果是,那么第一次重定向是由您的浏览器直接完成的,无需任何网络交互,因此无需担心。
-
@Tom 是的!很高兴知道!非常感谢。
-
所以我让你更新你的问题添加 HSTS 并验证我的答案:)