我的重定向和服务器检查在codeigniter中不能为我的index.php工作。
我有一个前端安装向导,codeigniter有4个步骤,第4步是最后一步。我正试图使它,如果用户已经经过了步骤,并已达到步骤4,将有权限访问网站上的域名/服务器。
目前我使用的代码一直重定向到我的安装URL的index.php,即使我已经完成了所有的步骤。
下面的代码是在我的主索引。php
if (!file_exists('install/index.php')) {
// Make sure we've not already tried this
if (strpos($_SERVER['REQUEST_URI'], '/install/')) {
header('Status: 404');
exit;
}
// Otherwise go to installer
header('Location: '.rtrim($_SERVER['REQUEST_URI'], '/').'/install/');
exit;
}
欢迎控制器public function index()
{
if (!file_exists('install/index.php')) {
// Make sure we've not already tried this
if (strpos($_SERVER['REQUEST_URI'], '/install/')) {
header('Status: 404');
exit;
}
// Otherwise go to installer
header('Location: '.rtrim($_SERVER['REQUEST_URI'], '/').'/install/');
exit;
} else {
$this->load->view('welcome_message');
}
}
您可以将此代码放在welcome controller
将代码放在控制器的index函数中
<>之前类Welcome扩展CI_Controller {公共功能索引(){/*重定向代码*/}公共职能评论(){echo '看这个!';}}