If $ _ SERVER [& #039; HTTP_REFERER & #039;] is used to jump to the Loginlogin page from the Topictopic page, the address displayed on the login page is localhostajzindex. phpHometopictopic. This address is correct. why do I use the redirect redirection address...
IfTopic/topicPage jumpLogin/loginPage usage$_SERVER['HTTP_REFERER']The address displayed on the login page is as follows:http://localhost/a/jz/index.php/Home/topic/topicThis address is correct. Why does the address on the address bar become like this after I use redirect to jump?http://localhost/a/jz/index.php/a/jz/index.php/Home/Login/login.html?
Why is the redirection address not the address previously stored in the session?
The following code redirects the login operation method under the login controller: $ url = $ _ SERVER ['http _ referer']; session ('URL', $ url ); var_dump (session ('URL'); if (! Isset (session ('res2 ') [0]) {// verify whether the generated session exists $ this-> display (); // if the session does not exist, the login page is displayed.} else {$ this-> redirect (session ('URL'); // if the session exists, the page is redirected}
Reply content:
IfTopic/topicPage jumpLogin/loginPage usage$_SERVER['HTTP_REFERER']The address displayed on the login page is as follows:http://localhost/a/jz/index.php/Home/topic/topicThis address is correct. Why does the address on the address bar become like this after I use redirect to jump?http://localhost/a/jz/index.php/a/jz/index.php/Home/Login/login.html?
Why is the redirection address not the address previously stored in the session?
The following code redirects the login operation method under the login controller: $ url = $ _ SERVER ['http _ referer']; session ('URL', $ url ); var_dump (session ('URL'); if (! Isset (session ('res2 ') [0]) {// verify whether the generated session exists $ this-> display (); // if the session does not exist, the login page is displayed.} else {$ this-> redirect (session ('URL'); // if the session exists, the page is redirected}
It should be$this->redirectResolved issues
Method 1:$_SERVER['HTTP_REFERER']Use the obtained contentstr_replaceRemove the previous part$url = str_replace('http://localhost/a/jz/index.php','',$url);
Method 2: Do not use$this->redirect(session('url'));Switchheader('location:'.session('url'));exit();