如何使用$ _SERVER ['HTTP_REFERER']查找该用户来自Google? [英] How can i use $_SERVER['HTTP_REFERER'] to find that user came from google?
本文介绍了如何使用$ _SERVER ['HTTP_REFERER']查找该用户来自Google?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以前从未使用过$_SERVER['HTTP_REFERER']
,而且我不知道如何通过单击Google搜索结果中的链接来使用它来找到该用户来我的网站.用户可以来自google.com,google.co.uk等.
I haven't used $_SERVER['HTTP_REFERER']
before and i dont knw how i can use that to find that user came to my site by clicking on a link in Google search results. User can come from google.com, google.co.uk etc....
不胜感激.
推荐答案
$url = $_SERVER['HTTP_REFERER'];
$query = parse_url ($url, PHP_URL_QUERY);
$host = parse_url ($url, PHP_URL_HOST);
if (strstr ($query, 'q=') && strstr ($host, 'google.')) {
// user came from google
else {
// user didnt come from google
}
这篇关于如何使用$ _SERVER ['HTTP_REFERER']查找该用户来自Google?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文