![](/img/trans.png)
[英]How to make http://example.com/test.php to http://example.com/index.php?do=test using .htaccess?
[英]How to track users origin PHP by using example.com/index.php?ref=origin
如何在PHP中跟踪用户来源,我看到人们使用这个ref =经常我不知道这个获取请求是如何工作的。
我的代码
$calling_url = mysql_real_escape_string($_SERVER['HTTP_REFERER']);
网址:
http://example.com/index.php?ref=http://externalsite.com/page.html 或
http://example.com/index.php?ref=http%3A%2F%2Fexternalsite.com%2Fpage.html
PHP:
$ref = mysql_real_escape_string(rawurldecode($_GET["ref"]));
// $ref will be "http://externalsite.com/page.html" in both cases
网址跟踪资源:
不知道你想要实现的目标。
如果用户来自您的网站之外,最好的办法是使用HTTP_REFERER。 如果有人要求您的服务器提供一个页面,那么就引用者而言,您将不得不接受他们的话。 无论是在URL中还是在浏览器中。 如果他们不想告诉你,你就无法做到。
即使它不那么可靠,它也会比依赖别人的应用程序更可靠。 除非涉及交易,否则会鼓励引荐人正确格式化网址。
如果用户在您自己的网站内移动。 您可以使用ref =策略,也可以使用会话变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.