首页 > 解决方案 > Codeigniter 总是重定向到同一个方法

问题描述

我在生产服务器上有一个系统,我想在本地模拟它来更新它,但是以前的程序员使用了一个奇怪的架构。第一个内部有一个codeigniter架构和另一个......

在我的本地机器上模拟这个我有很多乐趣,因为所有路径都是绝对的,yeepee。所以目前,它在我的本地主机上,配置正确,但是当我尝试登录时,页面只是重新加载。我发现控制器登录(so kanri/login/login)的方法登录被调用但总是路由到kanri/login/index

在索引页面上,只有一个表单重定向到kanri/login/login方法,所以即使简单的重定向也不起作用。

文件 kanri/route.php :

defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

主要的 .htaccess :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^kanri(/(.*))?$ kanri.php?/$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^user(/(.*))?$ user.php?/$2 [L]
</IfModule>

MY_控制器:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Controller extends CI_Controller {

public function __construct()
{
    parent::__construct();

    if($this->session->userdata('flag_admin_login')===FALSE || empty($this->session->userdata('flag_admin_login'))){
        //print "***".$this->session->userdata('member_id')."!!!!!";
        redirect('/', 'refresh');
    }
}
}

我的登录控制器:

class Login extends CI_Controller {
    public function __construct()
    {
        parent::__construct();
        echo $this->router->fetch_class() . "<br/>"; // display the controller
        echo $this->router->fetch_method() . "<br/>"; //display the method
    }

    public function index(){
        //all code commented
    }

    public function login(){
        //all code commented
    }
} 

我有很多工作要做,但我仍然坚持运行......感谢您的时间!

标签: php.htaccesscodeigniter

解决方案


解决方案非常简单......

$config['uri_protocol'] = 'REQUEST_URI';
$config['enable_query_strings'] = FALSE;

推荐阅读