我正在尝试从Apache迁移到Nginx。 我使用的是Nginx 1.8.1和PHP 5.6
Apache接受这样的URL:
domain.com/site/index.php/something
并用参数/ something调用index.php脚本。 这是我的WordPress的工作原理,但还有其他脚本依赖。
例如,我可以这样做:
domain.com/path/script.php/someparameter
我怎样才能在Nginx中工作?
编辑:我find了WordPress的解决scheme:
location /blog/ { try_files $uri $uri/ /blog/index.php?$args; }
但是,对于所有脚本,通用解决scheme是什么?
你可以使用重写。
例如,用尾随的/
重写所有的PHP脚本:
location / { rewrite ^/(.+\.php)(/.+) /$1?$2; try_files $uri $uri/ =404; }