当用户来自HTTP代码301/307时,HTTP_REFERER不工作


HTTP_REFERER not working when user comes from HTTP code 301/307

我用PHP写了一些简单的代码,从我的301重定向URL中保存了slug,这样我就知道有多少访问者来自该广告。但是,当用户来自301/307时,它不起作用。

示例:如果用户从301重定向url example.com/example来重定向url到example.com/example1,现在在example1页面中没有显示来自此链接的转介example.com/example:

<>之前$url = example.com/example;$data = "$url";$ j = 0;Foreach (count_chars($data, 1) as $i => $val) {$ j = $ + $ val;}$result = substr(isset($_SERVER['HTTP_REFERER']) ?$_SERVER['HTTP_REFERER']: ",$j);echo $结果;之前

不要依赖$_SERVER['HTTP_REFERER'],浏览器发送它是完全可选的,一些安全软件会在请求中阻止它。点击这里阅读更多内容

这是Referer Tracking的正常问题。你应该使用其他方法来跟踪广告。

最常用的选项是Get Parameters (offer.php?ref=sitexy)