两个网站nginx +重定向

时间:2015-09-02 14:14:47

标签: redirect nginx

我有以下nginx配置:

server
{
  listen 80;
  server_name server1.com;
  rewrite ^/(.*) http://www.server1.com permanent;
}

server
{
  listen 80;
  server_name server2.com;
  rewrite ^/(.*) http://www.server2.com permanent;
}

server
{
  listen 80;
  root /home/server1/;
  index index.php index.html index.htm;
  server_name www.server1.com;

  ...
}

server
{
  listen 80;
  root /home/server2/;
  index index.php index.html index.htm;
  server_name www.server2.com;

  ...
}

我的问题是,当我在浏览器中输入server2.com时,我被重定向到www.server1.com!其他一切都正常。知道为什么吗?

先谢谢!

0 个答案:

没有答案