Codeigniter在虚拟主机错误404中

时间:2015-11-09 13:35:31

标签: php codeigniter virtualhost codeigniter-3

codeigniter 3.0.2

关于我的localhost env config

  

PHP 5.2+ apache 2.4 +

打印我的本地主机CI日志:
INFO - 2015-11-09 21:06:35 --> Config Class Initialized
INFO - 2015-11-09 21:06:35 --> Hooks Class Initialized
DEBUG - 2015-11-09 21:06:35 --> UTF-8 Support Enabled
INFO - 2015-11-09 21:06:35 --> Utf8 Class Initialized
INFO - 2015-11-09 21:06:35 --> URI Class Initialized
DEBUG - 2015-11-09 21:06:35 --> No URI present. Default controller set.
INFO - 2015-11-09 21:06:35 --> Router Class Initialized
INFO - 2015-11-09 21:06:35 --> Output Class Initialized
INFO - 2015-11-09 21:06:35 --> Security Class Initialized
DEBUG - 2015-11-09 21:06:35 --> Global POST, GET and COOKIE data sanitized
INFO - 2015-11-09 21:06:35 --> Input Class Initialized
INFO - 2015-11-09 21:06:35 --> Language Class Initialized
INFO - 2015-11-09 21:06:35 --> Loader Class Initialized
INFO - 2015-11-09 21:06:35 --> Helper loaded: url_helper
INFO - 2015-11-09 21:06:35 --> Helper loaded: file_helper
INFO - 2015-11-09 21:06:36 --> Database Driver Class Initialized
INFO - 2015-11-09 21:06:40 --> Session: Class initialized using 'files' driver.
INFO - 2015-11-09 21:06:40 --> Controller Class Initialized
INFO - 2015-11-09 21:06:40 --> File loaded:       E:\phpStudy\WWW\newab\application\views\admin/login.php
INFO - 2015-11-09 21:06:40 --> Final output sent to browser
DEBUG - 2015-11-09 21:06:40 --> Total execution time: 6.1245

一切正常,一切正常!

关于虚拟主机env config

  

PHP 5.2+ Apache 2.2 +

打印虚拟主机CI日志:
INFO - 2015-11-09 20:22:56 --> Config Class Initialized
INFO - 2015-11-09 20:22:56 --> Hooks Class Initialized
DEBUG - 2015-11-09 20:22:56 --> UTF-8 Support Enabled
INFO - 2015-11-09 20:22:56 --> Utf8 Class Initialized
INFO - 2015-11-09 20:22:56 --> URI Class Initialized
INFO - 2015-11-09 20:22:56 --> Router Class Initialized
INFO - 2015-11-09 20:22:56 --> Output Class Initialized
INFO - 2015-11-09 20:22:56 --> Security Class Initialized
DEBUG - 2015-11-09 20:22:56 --> Global POST, GET and COOKIE data sanitized
INFO - 2015-11-09 20:22:56 --> Input Class Initialized
INFO - 2015-11-09 20:22:56 --> Language Class Initialized
ERROR - 2015-11-09 20:22:56 --> 404 Page Not Found: /index

报告404页面未找到,一切都是404!

为什么呢?比较它们,我发现 Loader Class Initialized 发生此错误。

我也试试$ config [' uri_protocol'],使用

  • PATH_INFO

  • REQUEST_URI

  • QUERY_STRING

它在我的本地主机中工作,但在虚拟主机中都是404,所以它无法获得它。

请帮帮我。

1 个答案:

答案 0 :(得分:1)

使用CodeIgniter 3.0.x时,所有控制器文件名都必须以大写字母开头。确保您的文件以这种方式命名。

例如,在/application/controllers/中,文件a_controller.php必须命名为A_controller.php

同样重要的是控制器文件中类名的首字母大写字母的规则。例如,这是错误的

class a_controller extends CI_Controller {

这是正确的。

class A_controller extends CI_Controller {