gpt4 book ai didi

PHP:如何获取引荐来源网址?

转载 作者:IT王子 更新时间:2023-10-28 23:57:43 25 4
gpt4 key购买 nike

我有一个页面 (index.php),客户可以在其中向我发送电子邮件。现在我想看看访问者来自哪个网站。

如何使用 PHP 获取 Referrer URL?我试过$_SERVER['HTTP_REFERER'] 但它一直是空的。我需要考虑什么变量?

这是我的 $_SERVER 包含的内容;我放了一些 ---- CENSORED ---- 出于隐私考虑,实际上有真正的值(value)。

array(31) {
["DOCUMENT_ROOT"]=>
string(33) "/home/anything/public_html/design"
["GATEWAY_INTERFACE"]=>
string(7) "CGI/1.1"
["HTTP_ACCEPT"]=>
string(129) "text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1"
["HTTP_ACCEPT_ENCODING"]=>
string(13) "gzip, deflate"
["HTTP_ACCEPT_LANGUAGE"]=>
string(14) "en-US,en;q=0.9"
["HTTP_CACHE_CONTROL"]=>
string(8) "no-cache"
["HTTP_CONNECTION"]=>
string(10) "Keep-Alive"
["HTTP_COOKIE"]=>
string(189) "__utma=76630272.1468291432.1367655794.1367669576.1367674157.3; __utmb=76630272.1.10.1367674157; __utmc=76630272; __utmz=76630272.1367655794.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)"
["HTTP_HOST"]=>
string(25) " ---- CENSORED ---- "
["HTTP_USER_AGENT"]=>
string(57) "Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.15"
["PATH"]=>
string(13) "/bin:/usr/bin"
["QUERY_STRING"]=>
string(0) ""
["REDIRECT_STATUS"]=>
string(3) "200"
["REMOTE_ADDR"]=>
string(10) "5.15.68.79"
["REMOTE_PORT"]=>
string(5) "57897"
["REQUEST_METHOD"]=>
string(3) "GET"
["REQUEST_URI"]=>
string(12) "/referer.php"
["SCRIPT_FILENAME"]=>
string(45) "/home/anything/public_html/design/referer.php"
["SCRIPT_NAME"]=>
string(12) "/referer.php"
["SERVER_ADDR"]=>
string(13) " ---- CENSORED ---- "
["SERVER_ADMIN"]=>
string(35) " ---- CENSORED ---- "
["SERVER_NAME"]=>
string(25) " ---- CENSORED ---- "
["SERVER_PORT"]=>
string(2) "80"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["SERVER_SIGNATURE"]=>
string(189) "
Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at ---- CENSORED ---- Port 80

"
["SERVER_SOFTWARE"]=>
string(125) "Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635"
["UNIQUE_ID"]=>
string(24) "UYUNcUPeiDsAABkR2eYAAAAj"
["PHP_SELF"]=>
string(12) "/referer.php"
["REQUEST_TIME"]=>
int(1367674225)
["argv"]=>
array(0) {
}
["argc"]=>
int(0)
}

最佳答案

$_SERVER['HTTP_REFERER'] 将为您提供推荐页面的 URL(如果存在)。如果用户使用书签或通过手动输入 URL 直接访问您的站点,http_referer 将为空。此外,如果用户 以编程方式 (CURL) 发布到您的页面,那么他们也没有义务设置 http_referer。您遗漏了所有 _,这是打字错误吗?

关于PHP:如何获取引荐来源网址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16374704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com