【发布时间】:2013-07-05 15:27:53
【问题描述】:
我有一个单一入口点的应用程序。在该应用程序中,我有以下行:
$url = !empty($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : "/";
这允许我在访问 URL 时像这样处理它们:
http://localhost/index.php/controller/action?get=variables
一切都很好,但我是强迫症,我想摆脱 URL 的 index.php 部分。无论我尝试了什么,都没有按预期工作。
RewriteRule ^(.+)$ /index.php/$1 [L]
#or
RewriteRule ^([^.]+)$ /index.php/$1 [L]
等等
其中一些在我的 nginx 错误日志中产生循环错误(重写太多),其中一些根本不起作用。
我在这里停滞不前。我怎样才能成功地重写这样的 URL? 请注意,我使用的是 Nginx 而不是 Apache)。
【问题讨论】:
标签: php url-rewriting nginx