[Go] php http_referer

Source: Internet
Author: User
Reprinted from: http://blog.csdn.net/amonest/article/details/6432530

PHP's $_server[' Http_referer ' records the address of the previous (jump to this page) anchor tag, which is empty if opened directly in the browser.

Look at the Uchome and Ecshop source code, found often used to $_server[' http_referer '] value. HTTP REFERER is part of the header, and when the browser sends a request to the Web server, it usually takes an HTTP REFERER to tell the server which page link I took from, and the server can get some information for processing. For example, if you link to a friend from my home page, his server will be able to count the number of users who click on the link on my page to visit his website from HTTP Referer. Below you have written an example to illustrate the various changes in Http_referer.

Please save the following code to a php file named referer.php:

Referer1 | Referer2 | Referer3
 
  
 
  

In the URL field, enter: http://localhost/hellophp/referer.php, execution results are as follows:

[]

Click Connect Refer1 to perform the following results:

[http://localhost/hellophp/referer.php]

Click Connect Refer2 to perform the following results:

[Http://localhost/hellophp/referer.php?p=referer1]

Click Connect Refer3 to perform the following results:

[Http://localhost/hellophp/referer.php?p=referer2]

Click Connect Refer1 to perform the following results:

[Http://localhost/hellophp/referer.php?p=referer3]

In the URL field, enter: Http://localhost/hellophp/referer.php?p=referer2, execution results are as follows:

[]

From the above process we can conclude that the value of $_server[' Http_referer '] is empty when a request is made to the Web server from the URL bar, $_server[' Http_referer ' When a request is made from the link to the Web server The value is the URL where the request was made.

  • 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.