Getting the referrer URL in php ( including parameters )

眉间皱痕 提交于 2019-12-31 00:56:23

问题


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?


回答1:


You should be able to grab it from the $_SERVER['HTTP_REFERER'] variable.




回答2:


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



来源:https://stackoverflow.com/questions/1183842/getting-the-referrer-url-in-php-including-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!