【问题标题】:nginx path rewritenginx路径重写
【发布时间】:2012-05-21 21:16:49
【问题描述】:

我得到的是:

/index.php/rest/item/1

但是,它应该是:

/rest/item/1

如何将每个请求从 /index.php/rest/ 重写为 /rest/ ?

谢谢!

编辑: 它似乎只有在我将其设为重定向时才有效:

rewrite ^/index.php/rest/(.*)$ /rest/$1 permanent;

如果我使用“break”或“last”,它会在我身上出现 404,知道吗?我正在使用 Gallery3,它是在 php 的 Konoha 框架上编写的。

【问题讨论】:

    标签: url-rewriting nginx rewrite


    【解决方案1】:

    过去几周我一直在与 Dmitry 合作解决这个问题,我们终于找到了问题所在。我只需要它确保它在处理规则时不会完成。从规则中删除“last”或“break”可以修复它:

    if (!-e $request_filename) {
            rewrite ^/index.php/rest/(.*)$ /rest/$1;
            rewrite ^/(.+)$ /index.php?kohana_uri=$1 last;
    }
    

    【讨论】:

      猜你喜欢
      • 2018-12-12
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 2019-08-27
      • 2019-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多