【发布时间】:2016-10-25 13:24:57
【问题描述】:
假设我在www.example.com 上使用nginx 运行服务。我有port:80 的全部流量。 https是必需的。我决定删除example.com/ 上的服务,并将用户直接移至example.com/dir/。
StackOverflow 上最流行的解决方案是添加
location = / {
return 301 /dir/;
}
不幸的是,它确实转发到http://www.example.com/dir/ 而不是https://www.example.com/dir/。我也试过:
location = / {
return 301 https://$http_host/dir/;
}
和
location = / {
return 301 https://$host/dir/;
}
但他们都失败了。
另一方面,我可以找到:
location / {
...
}
在这个文件中。
这里我有两个问题:
-
location = / {}和location / {}有什么区别? - 有什么配置技巧可以解决我的问题吗?
【问题讨论】:
标签: http nginx https configuration http-redirect