nginx rewrite的“找不到文件。”问题

我尝试将 htaccess 的设定档丢到线上去转成 nginx 的
直接转的完全不能用
于是我参考了一下原理去改成这样

location / {
    rewrite ^/admin/index$ /admin/templates/index.php;
    rewrite ^/admin/handlers/([\w\-]+)$ /admin/handlers/$1.php;
    rewrite ^/$ /public/templates/index.php;
    }

我发现 /, /admin/index 正常
但是我发现 /admin/handlers/ 失效了,他会说「File not found.」
其实在该目录下是有档案的
反而要在后面加上 .php 才会有反应,例如「/admin/handlers/signin.php」
这是哪里设定错误了?

https://imgur.com/EbVsiDE
https://imgur.com/XzlmYUg
https://imgur.com/7n3QD1h

阅读 3.7k
1 个回答

试着加上last或者break标志。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题