Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter redirect URL issue

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

like image 555
Akif Hussain Sayyed Avatar asked Apr 15 '26 22:04

Akif Hussain Sayyed


2 Answers

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

like image 122
Vishal Rambhiya Avatar answered Apr 17 '26 13:04

Vishal Rambhiya


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');
       }
}
like image 21
Bipin Kareparambil Avatar answered Apr 17 '26 12:04

Bipin Kareparambil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!