重定向时代码点火器中的 URL 更改


Url Change in codeigniter while redirecting

我是编码点火器的新手。

我正在尝试开发登录页面,它几乎完成了,但我不知道当我在成功登录后尝试重定向页面或在登录不成功后重定向时,url 的起始部分localhost:81更改为[::1]。我不知道为什么会发生,我用谷歌搜索它,但我没有得到正确的方法,所以请有人在下面帮助我,我提到了我的代码。

提前谢谢你。


这是用于验证电子邮件和密码的控制器代码

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class verifyLogin_controller extends CI_Controller {
function _construct(){
    parent::_construct();       
}
public function index()
{       
    if($_POST["submitLogin"])
    {
        $userEmail=$this->input->post('email');
        $password=$this->input->post('password');
        $verify_query = $this->db->from("admin");           
        $verify_query = $this->db->where(array("admin_userid" => $userEmail,"admin_password"=>$password));
        $verify_query = $this->db->limit(1);
        $res=$this->db->get()->result();            
        if($res != null)
        {
            redirect("homeHeader_controller/index");
        }
        else
        {
            redirect("adminLogin_controller/index");
        }
    }
}
}

设置您的base_url

$config['base_url'] = 'http://localhost:81/';

只需尝试添加以下代码:

$ark_root  = "http://".$_SERVER['HTTP_HOST'];
$ark_root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $ark_root;