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?
是否有任何HTTP标头我可以使用网络服务器/服务器端脚本来获取整个引用URL?包括查询字符串,等等?
2 个解决方案
#1
You should be able to grab it from the $_SERVER['HTTP_REFERER'] variable.
您应该能够从$ _SERVER ['HTTP_REFERER']变量中获取它。
#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.
要添加到Chacha的观点,我不知道您是否要捕获引荐来源URL的客户端哈希部分(有时,您这样做)。即如果客户来自“http://www.domain.com?x=3#y=5”,$ _SERVER ['HTTP_REFERER']将只包含“http://www.domain.com?x=3 “,并且哈希部分不会被发送到服务器。
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).
如果要捕获该哈希部分(官方称为URL片段),则只有在引用页面是您的OWN页面时才能这样做 - 即,如果您可以在该页面上编写代码。如果是,只需向您的统计Web服务发送一个AJAX请求,捕获引用,并发送整个URL(javascript可以访问该URL的那一部分)。
#1
You should be able to grab it from the $_SERVER['HTTP_REFERER'] variable.
您应该能够从$ _SERVER ['HTTP_REFERER']变量中获取它。
#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.
要添加到Chacha的观点,我不知道您是否要捕获引荐来源URL的客户端哈希部分(有时,您这样做)。即如果客户来自“http://www.domain.com?x=3#y=5”,$ _SERVER ['HTTP_REFERER']将只包含“http://www.domain.com?x=3 “,并且哈希部分不会被发送到服务器。
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).
如果要捕获该哈希部分(官方称为URL片段),则只有在引用页面是您的OWN页面时才能这样做 - 即,如果您可以在该页面上编写代码。如果是,只需向您的统计Web服务发送一个AJAX请求,捕获引用,并发送整个URL(javascript可以访问该URL的那一部分)。