为什么这个虚拟主机configuration保持redirect其他域到一个

我正在尝试向nginx添加第二个域。 可以访问domain2.com中的css这样的静态文件,但访问php脚本(例如domain2.com/index.php)将302redirect到domain1.com(例如domain1.com/index.php),所以我认为中断点必须在location ~ \.php$部分,但我不能确定它在哪里。 我被困在这里很长一段时间,我在哪里做错了? [操作系统:Windows 2008; Nginx的:1.0.12]

nginx.conf

 worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 50m; gzip on; server { listen 80; server_name _; server_name_in_redirect off; location / { root F:/Web/nginx/html/; index index.html; } } include F:/Web/nginx/vhosts/*.conf; } 

F:/Web/nginx/vhosts/domain1.com.conf

  server { listen 80; server_name domain1.com; charset utf-8; location / { root F:/domain1; index index.php; try_files $uri $uri/ /index.php?$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME F:/domain1/$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } 

F:/Web/nginx/vhosts/domain2.com.conf

 server { listen 80; server_name domain2.com; charset utf-8; location / { root F:/domain2; index index.php; try_files $uri $uri/ /index.php?$args; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME F:/domain2/$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } 

更新:

我find了原因。它不是nginxconfiguration问题,它是php-cgiconfiguration。 我设置了doc_root='F:/domain1'所以它保持redirect。

希望能帮助任何遇到这个问题的人。