If you jump from the Topic/topic
page to the Login/login
page using $_SERVER['HTTP_REFERER']
and then log in, the address of the page will be like this http://localhost/a/jz/index .php/Home/topic/topic
, this address is correct, why does the address on the address bar become like this after I use redirect? http://localhost/a/jz/index.php/a/jz /index.php/Home/Login/login.html?
And why is this jump address not the address previously stored in the session?
<code>以下是login控制器下login操作方法跳转部分的代码 $url=$_SERVER['HTTP_REFERER']; session('url',$url); var_dump(session('url')); if(!isset(session('res2')[0])){ //验证通过产生的session是否存在 $this->display(); //不存在session还显示login页面 }else{ $this->redirect(session('url')); //存在则跳转 }</code>
Topic/topic page to the
Login/login page using
$_SERVER['HTTP_REFERER'] and then log in, the address of the page will be like this
http://localhost/a/jz/index .php/Home/topic/topic, this address is correct, why does the address on the address bar become like this after I use redirect? http://localhost/a/jz/index.php/a/jz /index.php/Home/Login/login.html
? And why is this jump address not the address previously stored in the session?
<code>以下是login控制器下login操作方法跳转部分的代码 $url=$_SERVER['HTTP_REFERER']; session('url',$url); var_dump(session('url')); if(!isset(session('res2')[0])){ //验证通过产生的session是否存在 $this->display(); //不存在session还显示login页面 }else{ $this->redirect(session('url')); //存在则跳转 }</code>
$this->redirect
Method 1: Use
to remove the previous part of the content obtained by $_SERVER['HTTP_REFERER']
$url = str_replace('http://localhost/a/jz/index.php','' ,$url);
Method 2: Instead of using
jump, use header('location:'.session('url'));exit();