我正在尝试以下重写规则:
location / { index index.php index.html; rewrite ^/test$ /test.php break; }
我也有:
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /home/sites/default$fastcgi_script_name; fastcgi_index index.php; }
正常的PHP文件工作正常,但似乎我的redirect只是下载我redirect到的PHP文件,而不是parsing它。
我错过了什么? 我得到的文件加载,而不是下载通过把fastcgi的东西在第一个位置块,但它仍然没有parsing为PHP。
改变到last 。
由于新的URL需要在不同的location进行处理,因此需要对新重写的URL进行nginx重新启动处理,只有在rewrite规则中使用last时才会执行该操作。
请参阅文档以获得更全面的解释。