ThinkPHP redirect redirection and referer usage problems

Source: Internet
Author: User
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();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.