Getting the referrer URL in php ( including parameters )

前端 未结 2 1444
渐次进展
渐次进展 2021-01-18 19:10

Are there any HTTP Headers I could use to grab the entire referrer URL using a webserver/server-side scripting? Including query string, et cetera?

2条回答
  •  [愿得一人]
    2021-01-18 19:17

    To add to Chacha's point, I don't know if you want to capture the client side hash part of the referrer URL (sometimes, you do). I.e. if the client came from "http://www.domain.com?x=3#y=5", the $_SERVER['HTTP_REFERER'] will only contain "http://www.domain.com?x=3", and the hash part won't be sent up to the server.

    If you want to capture that hash part (officially called the URL fragment), you can only do so if the referring page is your OWN page - i.e. if you can write code on that page. If it is, just send up an AJAX request to your statistics web service that captures referrers, and send the entire URL up (javascript does have access to that part of the URL).

提交回复
热议问题