Kevin Koo
Kevin Koo

Reputation: 19

Codeigniter in virtual host error 404

codeigniter 3.0.2

About my localhost env config

PHP 5.2+ apache 2.4+

print my localhost CI Log:
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

It worked and everything is ok!


About Virtual Host env config

PHP 5.2+ Apache 2.2+

print Virtual Host CI Log:
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

It report 404 page not found and everything is 404!

why? compare them, i find at Loader Class Initialized occur this error.

I aslo try $config['uri_protocol'], use

it worked in my localhost but all 404 in Virtual Host, so it can't get it.

Please help me.

Upvotes: 2

Views: 693

Answers (1)

DFriend
DFriend

Reputation: 8964

With CodeIgniter 3.0.x it is essential that all controller file names start with an upper case character. Make sure your files are named this way.

For instance, in /application/controllers/ the file a_controller.php must be named A_controller.php

Equally important is the rule for an initial capital letter for the class name in the controller file. For instance this is wrong

class a_controller extends CI_Controller {

This is correct.

class A_controller extends CI_Controller {

Upvotes: 1

Related Questions