【问题标题】:Codeigniter in virtual host error 404虚拟主机中的 Codeigniter 错误 404
【发布时间】:2015-11-09 13:35:30
【问题描述】:

codeigniter 3.0.2

关于我的本地主机环境配置

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

成功了,一切正常!


关于虚拟主机环境配置

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,所以它无法获取它。

请帮助我。

【问题讨论】:

  • 介意发布您的htaccess 吗?
  • 您是否更改了配置文件中的基本网址?你能发布一些代码来看看你是如何加载索引的吗​​?
  • @TerisL 我不使用 .htaccess。
  • @jpganz18 $config['base_url'] = '' 我没有设置它。关键是在我的本地主机上它工作,发布到虚拟主机它不工作然后 404
  • @jpganz18 base_url 可能不是这个错误的原因,我通过重命名的文件名以大写字符开头得到它。

标签: php codeigniter virtualhost codeigniter-3


【解决方案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 {

【讨论】:

  • 你是对的!我通过重命名的文件名得到它。非常感谢。
猜你喜欢
  • 2014-11-29
  • 2017-03-21
  • 2016-07-08
  • 1970-01-01
  • 2015-04-05
  • 2019-01-01
  • 2017-05-27
  • 2015-07-09
  • 2017-08-15
相关资源
最近更新 更多