如何确定具有target=“”的外部链接的推荐人_空白”;

How to determine Referrer for external links with target="_blank"?

本文关键字:推荐人 链接 空白 外部 何确定 target      更新时间:2023-09-26

我无法使用PHP:捕获Referrer

$_SERVER['HTTP_REFERER'];

当访问者通过target="_blank"的链接从外部网站访问mywebsite.com时,例如:

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

它总是返回空结果,而不是外部网站.com

是否可以正确地获得外部网站.com,比如说使用JavaScript和PHP的组合或其他东西?

提前感谢!

我想我找到了这个问题的解决方案。我建议我有一个php文件。所以我想要直接和_blank链接rediret ru.example.com和引用链接az.example.com。我有这个链接az.exexample.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/');
}
...
}
?>