【发布时间】:2012-10-17 15:23:01
【问题描述】:
目前我有这段代码:
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
这适用于以下情况:
example.com/foo 重定向到 index.php
但是example.com/foo?bar 不起作用。你是如何让它发挥作用的?
FWIW:我在 Apache 的 mod_rewrite 等效项中没有遇到这个问题。基本上,我将一个可以工作的站点从 Apache 转移到 Nginx。现在我遇到了这个问题。
编辑:
要清楚这是我要做的事情:
example.com/fooexample.com/foo/bar/etcexample.com/foo?barexample.com/foo?bar=quz
应该全部“静默”地提供index.php,而不更改浏览器地址栏的URL。
【问题讨论】:
标签: php mod-rewrite url-rewriting nginx rewrite