Home >Backend Development >PHP Tutorial >Get the url before jumping
For example, modify a link from Taobao, jump to a.php
, and then a.php redirects hedader_location to b.php
Use http_referer in b.php to get the Taobao url. How can I get the middle page a.php?
I don’t want to pass the value in a.php, because there are many pages that jump to b.php, and it is too troublesome to process each intermediate page
For example, modify a link from Taobao, jump to a.php
, and then a.php redirects hedader_location to b.php
Use http_referer in b.php to get the Taobao url. Please tell me. How can I get the middle page a.php?
I don’t want to pass the value in a.php, because there are many pages that jump to b.php, and it is too troublesome to process each intermediate page
First of all, if you don’t pass a value in the URL, or other session cookies, the only way to get the destination is reffer.
But:
From the results of this matter
When the browser opens a 301 link, it actually requires the browser to re-request the newly provided 301 target address. Then the browser directly re-requests the new page without bringing the 301 URL. The result is that the server and client do not have any record of the 301 page URL information, and no one can obtain it.
To give an example in life, we bought a connecting ticket. When we got on the second plane, even though you took out the ticket, the plane told you that there was a problem with the plane and asked you to take another flight. Then we took this ticket and took another plane. When this plane saw the ticket, it only knew which plane you were on, but did not know which plane you transferred to. The ticket is the http-reffer that is brought up every time the browser requests it
This is also mentioned in some user privacy policies of the http protocol. It is not mandatory, it just means that it is not necessary. If the http reffer is recorded as a jump page, then clicking the browser to return will return to your own page, so this approach makes sense logically.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.36
https://www.w3.org/Protocols/rfc2616/rfc2616-sec15.html
document.referrer
If you don’t consider IE67, you can use localstorage in h5. Cookies can also be implemented