Codeigniter重定向URL问题

I am new to codeigniter. I have just made a login feature in CI with the help of google, but here I am redirecting to URL on login but It is not working. Here is the details after redirecting the link is like this http://localhost/xpensepedia/index.php/home which is giving the 404 error

404 Page Not Found
The page you requested was not found.

and my controller is

public function index() {
        $this->load->view('header');
        if (($this->session->userdata('user_id') != "")) {
            redirect(site_url('home'));
        } else {
            $this->load->view("register");
        }
    $this->load->view('footer');
}

My files are in the image enter image description here

Kindly check name of class you given to home.php Controller

you can add url path on constraints .... you define the url like this on constants :

define('ROUTE_STIE_PATH','localhost/xxx'); 
define('ROUTE_STIE_PATH_LOGIN',ROUTE_STIE_PATH.'login/'); 
define('ROUTE_STIE_PATH_HOME',ROUTE_STIE_PATH.'home/');

and then you can echo by simply

echo ROUTE_STIE_PATH_LOGIN

if you want to call any methods with in home then

echo ROUTE_STIE_PATH_HOME.'methodname';

Try this...

public function index() {

    if (($this->session->userdata('user_id') != "")) {
        redirect(site_url('home'));
    } else {
        $this->load->view('header');
        $this->load->view("register");
        $this->load->view('footer');
    }

}

Home Controller :

class Home extends CI_Controller {
       Public function index {
          $this->load->view('header');
          $this->load->view("home");
          $this->load->view('footer');
       }
}

I solve similar case when I change my config file located in application>config>config.php to the following value:

$config['base_url'] = '';
$config['uri_protocol'] = 'REQUEST_URI';