在Nginx中复制Apache Multiviews + PATH_INFO

我正在使用之前使用Apache + Multiviews + PATH_INFO的一些旧的PHP代码。 我现在试图使用nginx(我使用和崇拜我所有的其他更新的工作)启动和运行此网站。

问题在于/ books / newreleases / 1420之类的URL,它实际上需要由/books.php来处理(以便php能够看到/books.php/newreleases/1420以及适当的PATH_INFO信息)。

我知道所有这些使用多视图的原因是一个坏主意,但重新开发这个网站来解决这个问题目前还不是一个select。

我可以通过使用rewrite( rewrite ^/books/(.*)$ /books.php/$1; )来使这个特定的例子工作rewrite ^/books/(.*)$ /books.php/$1;但是整个站点中有太多的文件来为每个东西进行重写的手动编码除了最后的手段。 另外,这让我难过。

我一直在阅读这里所有类似的问题,但无法find这个具体案例的答案,我也不知道是否有一个正确的方法来使用try_files来处理它。

这里是我的configuration肉:

 server { server_name foo.com www.foo.com; root /srv/www/foo.com/public_html; rewrite_log on; index index.html index.htm index.php; location / { rewrite ^/books/(.*)$ /books.php/$1; try_files $uri $uri.php $uri/ =404; } location ~ ^.+\.php { try_files $uri.php $uri/ =404; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9050; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; } }