【发布时间】:2013-11-15 23:28:26
【问题描述】:
我正在将我的 codeigniter 文件从 apache 迁移到 nginx,并查看 nginx 的重写。我遇到了以下重写以删除 codeigniter index.php
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
重写有效。但是,我完全不明白/index.php?/ 部分。
更新:
我尝试重写没有问号,例如rewrite ^/(.*)$ /index.php/$1 last;。它适用于普通控制器,但当第三方(如/controller?code=something)将值发布到控制器时会中断。
我的问题
1) 问号在这次重写中的作用是什么?这会使 index.php 成为可选的吗?
2) 此外,codeigniter 不会像在 get 请求中那样路由带有问号的 url。比如这样的get请求
http://example.com/controller?code=somecodehere
中断并且不调用控制器,而是试图直接调用controller?code=somecodehere。这个路由可以解决这个问题,但我就是不明白怎么做。
对此重写的任何见解都会有所帮助。
谢谢。
【问题讨论】:
标签: codeigniter nginx rewrite url-routing