nginx网站无法加载正确的域

时间:2016-11-04 11:34:58

标签: nginx

我有几个域在nginx上工作正常。我现在试图添加另一个,但它不断提出另一个域。

这是可用的配置文件之一,在尝试进入新域时始终会加载。

server {
    listen       80;
    server_name   www.domain1.com;
    return       301 http://domain1.com$request_uri;
}
server {
    listen   80;

    root /data/domain1.com/www;
    index index.php index.html index.htm;

    server_name domain1.com;

    error_log /data/domain1.com/logs/error.log error;
    access_log /data/domain1.com/logs/access.log;



    location ~ [^/].php(/|$) {
        fastcgi_split_path_info ^(.+?.php)(/.*)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 365d;
    }

}

这是我用于新手的那个:

server {
    listen       80;
    server_name   www.domain2.com;
    return       301 http://domain2.com$request_uri;
}
server {
    listen   80;

    root /data/domain2.com/www;
    index index.php index.html index.htm;

    server_name domain2.com *.domain2.com www.domain2.com;

    error_log /data/domain2.com/logs/error.log error;
    access_log /data/domain2.com/logs/access.log;



    location ~ [^/].php(/|$) {
        fastcgi_split_path_info ^(.+?.php)(/.*)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 365d;
    }

}

如果我删除第一个文件,则新域加载正常。

0 个答案:

没有答案