如何确定目标=“_blank”的外部链接的Referrer?

发布于 2025-01-07 12:18:32 字数 511 浏览 4 评论 0原文

我无法使用 PHP 捕获引荐来源网址:

$_SERVER['HTTP_REFERER'];

当访问者通过 target=" 的链接从 external-web-site.com 访问 mywebsite.com 时_blank",例如:

   ...    
   <a href="http://mywebsite.com" target="_blank">Link to My WebSite</a>
   ...

总是返回空结果而不是 external-web-site.com

是否可以正确获取 external-web-site.com,可以说使用 JavaScript 和 PHP 的组合或其他东西 别的?

提前致谢!

I am unable to catch the Referrer using PHP:

$_SERVER['HTTP_REFERER'];

when visitors come to mywebsite.com from an external-web-site.com via a link with target="_blank", for ex:

   ...    
   <a href="http://mywebsite.com" target="_blank">Link to My WebSite</a>
   ...

It always returns empty result instead of the external-web-site.com

Does it possible to correctly obtain external-web-site.com, lets say using combination of JavaScript and PHP or something else?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如日中天 2025-01-14 12:18:32

我想我找到了这个问题的解决方案。我建议我有一个 php 文件。所以我想要直接和_blank链接rediret ru.example.com和引用链接az.example.com。我有这个链接 az.example.com/index.php?id=123 我想要来自 facebook.com 或其他网站的 _blank 链接,我的页面不重定向。只重定向index.php

所以

index.php源代码:

<?php
$refer = $_SERVER['HTTP_REFERER'];
...
if($id<>null){
...
}else{
if($refer==null){
header('Location:http://ru.example.com/');
}
...
}
?>

I think i found this problem solution. I am suggesting that i have one php file. So i want direct and _blank link rediret ru.example.com and referred link az.example.com. And i have this link az.example.com/index.php?id=123 i want _blank link from facebook.com or another site my page not redirect. Only redirect index.php

so

index.php source code:

<?php
$refer = $_SERVER['HTTP_REFERER'];
...
if($id<>null){
...
}else{
if($refer==null){
header('Location:http://ru.example.com/');
}
...
}
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文