Search code examples
phpcodeigniterloggingmessage

Codeigniter ERROR --> 404 Page Not Found --> public


I have this log_message error and I don't know why?

DEBUG - 2016-10-26 19:06:38 --> Final output sent to browser
DEBUG - 2016-10-26 19:06:38 --> Total execution time: 0.0583
DEBUG - 2016-10-26 19:06:38 --> Config Class Initialized
DEBUG - 2016-10-26 19:06:38 --> Hooks Class Initialized
DEBUG - 2016-10-26 19:06:38 --> Utf8 Class Initialized
DEBUG - 2016-10-26 19:06:38 --> UTF-8 Support Enabled
DEBUG - 2016-10-26 19:06:38 --> URI Class Initialized
DEBUG - 2016-10-26 19:06:38 --> Router Class Initialized
**ERROR - 2016-10-26 19:06:38 --> 404 Page Not Found --> public**
DEBUG - 2016-10-26 19:06:39 --> Config Class Initialized
DEBUG - 2016-10-26 19:06:39 --> Hooks Class Initialized
DEBUG - 2016-10-26 19:06:39 --> Utf8 Class Initialized

And the controller

 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Users extends Admin_Controller{

    public function __construct()
    {
        parent::__construct();

        // Load user model
        $this->load->model('user_model');
    }

    public function index()
    {
        $this->load->view('admin/layouts/users_view');
        $this->load->view('admin/templates/footer');
    }

    public function get_users(){

        echo  $this->user_model->get_users();

    }

}

get_users function get data for Datatables with Datatables librery. Called from view with ajax.


Solution

  • Why does your controller extends the Admin_Controller if all i can see is only basic Codeigniter methods, why not have it extend the main CI_Controller?

    Maybe this is your problem, in order to use a controller in Codeigniter, it must extend the CI_Controller in order to inherit all of its methods ($this) unless you want to make a library or a helper, they don't need to extend the CI_Controller.

    • Make sure your page is respecting these rules : Class name and the controller file name Must be the same, ex : class : User, controller file : User.php
    • Make sure your roues aren't overriding your controller with a nonexistent link.
    • Make sure your views are in the right path, unless it might pop up a 404 error.