1

我有一个单一入口点的应用程序。在该应用程序中,我有以下行:

$url = !empty($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : "/";

这允许我在访问 URL 时处理它们,如下所示:

http://localhost/index.php/controller/action?get=variables

一切都很好,但我是强迫症,我想摆脱index.phpURL 的一部分。无论我尝试了什么,它都没有按预期工作。

RewriteRule ^(.+)$ /index.php/$1 [L]
#or
RewriteRule ^([^.]+)$ /index.php/$1 [L]

等等

其中一些在我的 nginx 错误日志中产生循环错误(重写太多),其中一些根本不起作用。

我在这里停滞不前。我怎样才能成功地重写这样的 URL?请注意,我使用的是 Nginx 而不是Apache)

4

1 回答 1

1

负前瞻。

RewriteRule ^(?!index\.php)(.*)$ /index.php/$1 [L]
于 2013-07-05T07:27:53.070 回答