答案 0 :(得分:1)
对于记录,看起来这是一个更好的方法,因为它完全避免了正则表达式:
server {
listen 80;
server_name myserver.com;
return 301 https://$server_name$request_uri;
}
答案 1 :(得分:0)
server {
listen 80;
server_name _ *;
rewrite ^(.*) https://$www.example.com$1 permanent;
}
server {
listen 443;
server_name _ *;
}
答案 2 :(得分:0)
根据
,以下方法更好http://wiki.nginx.org/Pitfalls#Taxing_Rewrites
server {
listen 80;
server_name signup.mysite.com;
rewrite ^ https://$server_name$request_uri? permanent;
}