首页 > 解决方案 > 调用 Codeigniter 控制器方法不起作用

问题描述

我开始使用 CI 进行开发,我试图调用另一个我调用LOGIN的控制器,但它让我收到错误“未找到”,而如果我将控制器放在 default_controller 中,它可以工作,我已经阅读了另一个论坛关于这个问题,但它不能解决我的情况,

class Login extends CI_Controller {

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

}

标签: phpcodeigniter

解决方案


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


推荐阅读