我想将网站重定向到www.site.com.但是,我不确定如何让WWW始终显示在前面应该说有人在没有www的域中键入.
编辑:
server { listen 80; server_name site.com; rewrite ^(.*) https://www.site.com$1 permanent; } server { listen 80; server_name www.site.com; #rewrite ^(.*) https://www.site.com$1 permanent; root /home/site/public_html; listen 443 ssl;
如果我输入site.com,则转到https://www.site.com = SUCCESS
如果我输入site.com/index.PHP,则会转到http://www.site.com = NO SSL
想法?
解决方法
你这么做很难.这是简单的方法.
server { listen 80; server_name example.com; rewrite ^(.*) http://www.example.com$1 permanent; } server { listen 80; server_name www.example.com; #The rest of your configuration goes here# }