Codeigniter 错误 --> 404 页面未找到 --> public

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

我有这个 log_message 错误,我不知道为什么?

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

和控制器

 <?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 函数使用数据表库获取数据表的数据。 使用 ajax.

从视图中调用

如果我只能看到基本的 Codeigniter 方法,为什么你的控制器扩展了 Admin_Controller,为什么不扩展主要的 CI_Controller

也许这是你的问题,为了在 Codeigniter 中使用控制器,它必须扩展 CI_Controller 以继承它的所有方法($this),除非你想创建一个库或帮手,他们不需要扩展 CI_Controller.

  • 确保您的页面遵守这些规则:Class 名称和 控制器文件名必须相同,例如:class:用户,控制器 文件:User.php
  • 确保您的路由没有使用 不存在 link。
  • 确保您的视图在正确的路径中,除非它可能弹出 出现 404 错误。