【发布时间】:2011-04-14 17:38:34
【问题描述】:
我将 CodeIgniter 用于两个应用程序(一个公共应用程序和一个管理应用程序)。 文档结构的重要元素是:
/admin
/admin/.htaccess
/admin/index.html
/application
/application/admin
/application/public
/system
.htaccess
index.php
/admin/.htaccess 文件如下所示:
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
/admin/index.php 有以下变化:
$system_folder = "../system";
$application_folder = "../application/admin"; (this line exists of course twice)
并且 /application/admin/config/routes.php 包含以下内容:
$route['default_controller'] = "welcome";
$route['admin'] = 'welcome';
Welcome 是我的默认控制器。
当我调用域/管理员时,我收到 404 Page Not Found 错误。当我调用域/管理员/欢迎时,一切正常。在调试日志中,我收到以下错误消息:
DEBUG - 2010-09-20 16:27:34 --> Config Class Initialized
DEBUG - 2010-09-20 16:27:34 --> Hooks Class Initialized
DEBUG - 2010-09-20 16:27:34 --> URI Class Initialized
ERROR - 2010-09-20 16:27:34 --> 404 Page Not Found --> admin
奇怪的是,这个设置在我的本地 MAMP 安装(使用 localdomain/admin/)上完美运行,但是当我在“实时”服务器上发布和测试它时,我只收到 404 错误。
有什么想法吗?我究竟做错了什么? 谢谢 C.
【问题讨论】:
-
只是想一想,也许实时服务器没有运行 mod_rewrite?直播服务器只给你404还是偶尔给你?
-
它似乎工作正常 - 我刚刚通过捕获所有非 www 域并重定向到 google.com 对其进行了测试。 404 错误肯定是由 CI 生成的(因为它们使用 CSS)。
-
只是想发布一下,如果您正在运行 Codeigniter 3 的新安装并且您在托管文件夹的名称中有一个空格,它将提供 404。版本 3.0.0
标签: php codeigniter routes http-status-code-404