dongshou7903
dongshou7903
2019-07-17 06:46
浏览 74
已采纳

调用Codeigniter控制器方法不起作用

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");
    }

}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanhuayong6687
    duanhuayong6687 2019-07-17 07:41
    已采纳

    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

    点赞 评论
  • douxiluan6555
    douxiluan6555 2019-07-17 09:20

    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

    点赞 评论

相关推荐