doudou
doudou

Reputation: 50

Calling Codeigniter controller method not working

I'm starting to develop with CI, I'm trying to call another controller that I call LOGIN but it gets me the error "NOT FOUND", whereas if I put my controller in default_controller, it works, I already have read the other forum about this problem but it does not solve my case,

class Login extends CI_Controller {

    public function index() {
        redirect("/welcome/index");
        $this->load->view("login");
    }

}

Upvotes: 0

Views: 2037

Answers (2)

Justin J
Justin J

Reputation: 832

Possible solutions 1. Please add .htaccess to the codigniter

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2. Can create a routing for login controller then you can call directly 3. Add $config['index_page'] = 'index.php'; in config.php

Upvotes: 1

Jimit H.
Jimit H.

Reputation: 195

Solution -1

class Login extends CI_Controller {

        public function index() {
            redirect("index.php/welcome/index");
            $this->load->view("login");
        }

    }

Solution-2

application/config/config.php file you not remove index.php

$config['index_page'] = 'index.php';

change it

$config['index_page'] = '';

and using .htaccess index.php remove.

Reference link: index.php from URL

Upvotes: 0

Related Questions