nginx重写或内部redirect,主脚本未知

我正在从Apache转换为Nginx。 有关的应用程序如下

/ contentlibrary_js /contentlibrary_js/app/index.php – >一页ajax应用程序/contentlibrary_js/pagecreator/index.php – > codeigniter应用程序后端

我希望有一个服务器块处理请求到前端和请求到后端。

通过以下configuration,我在nginx错误日志中收到“重写或内部redirect周期,同时在内部redirect到”/index.php“。

我试图添加第二个位置块来处理对pagecreator / index.php文件的请求,但是我然后应用程序挂起等待响应,并且在读取来自上游的响应标头时,我得到“在stderr中发送的FastCGI:”主脚本未知“在错误日志中。

任何build议,谢谢

server { server_name contentlib.dev; #access_log logs/leonardo.access.log main; root /Users/acasanova/projects/mednet/contentlibrary_js; index index.html index.htm index.php; try_files $uri $uri/ /pagecreator/index.php /index.php /index.php$uri /index.php?$args; # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # Codeigniter # location /pagecreator/{ # try_files $uri $uri/ index.php$request_uri; # #root /Users/acasanova/projects/mednet/contentlibrary_js/pagecreator; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /Users/acasanova/projects/mednet/contentlibrary_js/pagecreator$fastcgi_script_name; # include fastcgi_params; # } location ~ [^/]\.php(/|$) { #GC # try_files $uri $uri/ /index.php$uri /index.php?$args; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } location ~ /\.ht { deny all; } } 

看来我很难理解try_file指令将允许访问其他位置块。 我一直在想,一旦请求匹配一个位置,那么这是唯一要处理的位置块。

 server { server_name contentlib.dev; access_log logs/contentlibrary_access.log; root /Users/acasanova/projects/mednet/contentlibrary_js; #default_type text/html; index index.php index.html index.htm; location /app{ try_files $uri $uri/ /index.php /index.php$uri =404; root /Users/acasanova/projects/mednet/contentlibrary_js/app; } location ~* \.(jpg|jpeg|gif|png|html|css|zip|tgz|gz|rar|doc|xls|pdf|ppt|tar|wav|bmp|rtf|swf|flv|txt|xml|docx|xlsx|js)$ { try_files $uri $uri/ /index.php$uri =404; access_log off; } location /pagecreator{ try_files $uri /index.php index.php$uri =404; root /Users/acasanova/projects/mednet/contentlibrary_js/pagecreator; } location ~ [^/]\.php(/|$) { #GC fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }