Search code examples
phpcodeigniterion-auth

Error 404 on logout function (Ion Auth) using Codeigniter


Calling this function to redirect me to the login webpage throw me '404 Error : the page you requested was not found'. I have followed the same steps that i followed for another application and it worked fine. Any Ideas?

Link

<li>
                            <a href="<?= base_url('auth/logout') ?>">Salir</a>
                        </li>

Ion Auth function

// log the user out
public function logout() {
    $this->data['title'] = "Logout";

    // log the user out
    $logout = $this->ion_auth->logout();

    // redirect them to the login page
    $this->session->set_flashdata('message', $this->ion_auth->messages());
    redirect('auth/login', 'refresh');
}

Base_url

$config['base_url'] = 'http://localhost/herba/';

Solution

  • Change this

    public function logout() {
        $this->data['title'] = "Logout";
    
        // log the user out
        $logout = $this->ion_auth->logout();
    
        // redirect them to the login page
        $this->session->set_flashdata('message', $this->ion_auth->messages());
        redirect(base_url('auth/login'), 'refresh');
    }
    

    please make sure http://localhost/herba/auth/login exist

    Also check with index.php

    http://localhost/herba/index.php/auth/login