【发布时间】:2012-07-07 07:09:06
【问题描述】:
所以,我正在使用我正在构建的 PHP 应用程序玩一些 url。
我正在使用 .htaccess 使用 mod_rewrite。看起来是这样的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
</IfModule>
我想如果一个 URL 是这样写的:
http://localdomain.com/controller
我希望作为 $_SERVER['PATH_INFO'] 的一部分的“控制器”结束时不会出现问题。但是,在运行 Apache 2.2.22 的 Ubuntu 12.04 上,我得到了 404 Not Found 错误:
NOT FOUND
The requested URL /index.php/controller was not found on this server.
似乎在 index.php 后面的斜杠后正确处理了“控制器”,但是有谁知道为什么我得到的是 404 而不是预期的响应?
最终,我试图捕获“控制器”以在我正在构建的 MVC 框架中使用。
在这种情况下,我有一个非常简单的 index.php,只有以下内容:
<?php
echo $_SERVER['PATH_INFO'];
然而,我仍然收到 404 错误,而不是预期的路径信息。
注意:仅使用 http://localdomain.com/ 或 http://localdomain.com/index.php 即可完美运行。 mod_rewrite 已打开且正在工作,并且 AllowOverride 设置为 All。
【问题讨论】:
标签: php apache mod-rewrite