Nginx和try_苍蝇工作不正常

Nginx和try_苍蝇工作不正常,nginx,rewrite,multiviews,Nginx,Rewrite,Multiviews,我正在尝试模拟多视图,但try\u文件有问题。一切正常,但我想将所有未管理的URL重写为/index.php(但不适用于404): 所有URL都将重写为/index.php。如果我删除第一个位置末尾的/index.php,那么除了非托管url(我希望被重写为index)之外,一切都正常。有什么想法吗?谢谢正如您所说,您可以尝试从第一个位置删除/index.php。然后,如果没有找到php文件,要使其重定向到/index.php,可以在处理.php请求的位置中添加几行代码: location ~

我正在尝试模拟多视图,但try\u文件有问题。一切正常,但我想将所有未管理的URL重写为/index.php(但不适用于404):


所有URL都将重写为/index.php。如果我删除第一个位置末尾的/index.php,那么除了非托管url(我希望被重写为index)之外,一切都正常。有什么想法吗?谢谢

正如您所说,您可以尝试从第一个位置删除
/index.php
。然后,如果没有找到php文件,要使其重定向到
/index.php
,可以在处理
.php
请求的
位置中添加几行代码:

location ~ \.php$ {
    if (!-f $request_filename) {
        rewrite    .*    /index.php;
    }
    # your other directives such as fastcgi_pass 127.0.0.1:9000; etc.
}
location ~ \.php$ {
    if (!-f $request_filename) {
        rewrite    .*    /index.php;
    }
    # your other directives such as fastcgi_pass 127.0.0.1:9000; etc.
}