【发布时间】:2015-06-07 08:15:45
【问题描述】:
我正在使用 HMVC 运行 CI 3.0。在我的本地 XAMPP 上一切正常,但在我的 (linux) 实时服务器上,我收到来自 CI 的错误 404 (Page Not Found)。
我有几个小时,尽我所能解决这个问题..没有成功!
这是我现在拥有的:
$route['default_controller'] = 'default';
htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
我的结构:
-应用
--模块
---默认
----控制器
-----Default.php
我的控制器 Default.php:
class Default extends MY_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
....
}
}
CI 错误日志中的错误:
错误 - 2015-04-02 13:15:56 --> 404 页面未找到:../modules/default/controllers//index
..仍然是 404。这有什么问题???
【问题讨论】:
-
确保您的
Controller文件名以大写字母开头。Index.php -
控制器需要命名为 Default.php 而不是 index.php 如果我说对了。路径中还有一个足够的斜杠,因此请检查它是如何调用的。另外Index(索引)是CodeIgniter中的保留名称,因此您要考虑将其更改为其他名称。
-
同意所有这些。另外,我的意思是 Index.php 控制器。最后,如果您检查他的文件和文件夹结构,我之前的评论将更加清晰。我的评论也发给@Kamran Adil。
标签: codeigniter