我有几个域名在 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;
}
}
如果我删除第一个文件,新域名就可以正常加载。