php - Codeigniter 总是重定向到同一个方法
问题描述
我在生产服务器上有一个系统,我想在本地模拟它来更新它,但是以前的程序员使用了一个奇怪的架构。第一个内部有一个codeigniter架构和另一个......
- 应用
- 管理员(哪些内容控制器和模型......可能未使用)
- 通用(语言和模型...)
- 控制器
- js(为什么在这里...)
- 关里
- 缓存、配置、控制器、核心、助手、模型、视图...
- 用户
- 缓存、配置、控制器、核心、助手、模型、视图...
- 系统
- ETC...
在我的本地机器上模拟这个我有很多乐趣,因为所有路径都是绝对的,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
}
}
我有很多工作要做,但我仍然坚持运行......感谢您的时间!
解决方案
解决方案非常简单......
$config['uri_protocol'] = 'REQUEST_URI';
$config['enable_query_strings'] = FALSE;
推荐阅读
- python - 有没有更好的方法来平均两个温度传感器输入?
- performance - 简单统计 NPM 包的每秒操作数在外行术语中意味着什么?
- amazon-web-services - ECS 按标签定义任务
- php - Slim 应用程序自动加载
- c# - 使用数据集填充 dataGridView
- python - 用另一个列表中的项目替换列表中的项目
- typescript - Angular Reactive Form Control Errors:如何读取错误对象
- openssl - 从 RSA_public_decrypt 获取解密消息?
- php - 单点登录 - 工作流程
- javascript - 解决 Promise 或在 Array push() 方法后添加回调