Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何根据推荐人重定向和/或延迟?_Php_.htaccess_Redirect_Referrer - Fatal编程技术网

Php 如何根据推荐人重定向和/或延迟?

Php 如何根据推荐人重定向和/或延迟?,php,.htaccess,redirect,referrer,Php,.htaccess,Redirect,Referrer,我想只允许从某个引用URL(如“example.com/123”)访问我的网站。我想在一个特定的延迟后,比如说1或2分钟,将其余的流量重定向到同一个引用URL。我想要交通 这来自example.com/123,不再提及 我曾想过使用类似的东西,但我不知道如何编辑以满足我的要求: <?php $referrer = $_SERVER['HTTP_REFERER']; if (preg_match("/site1.com/",$referrer)) { header('Locati

我想只允许从某个引用URL(如“example.com/123”)访问我的网站。我想在一个特定的延迟后,比如说1或2分钟,将其余的流量重定向到同一个引用URL。我想要交通 这来自example.com/123,不再提及

我曾想过使用类似的东西,但我不知道如何编辑以满足我的要求:

<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/site1.com/",$referrer)) {
      header('Location: http://www.customercare.com/page-site1.html');
} elseif (preg_match("/site2.com/",$referrer)) {
      header('Location: http://www.customercare.com/page-site2.html');
} else {
      header('Location: http://www.customercare.com/home-page.html');
};
?>

您的php脚本中需要有一些内容影响页面的标题,而不是实际服务器响应的标题

因此,在生成页面标题的脚本部分,您需要如下内容:

<!-- this is the header of your page -->
<head>
  <title>Your Title</title>
  <?php
    $referrer = $_SERVER['HTTP_REFERER'];

    // if referer isn't from example.com/123 we setup a redirect
    if ( !strstr($referrer, '://example.com/123') )
       print ('<META HTTP-EQUIV=Refresh CONTENT="60; URL=http://example.com/123">\n');

    ?>
  <!-- maybe some other stuff -->
</head>
它告诉浏览器重定向到URL(在本例中为
http://example.com/123
)60秒后

<META HTTP-EQUIV=Refresh CONTENT="60; URL=http://example.com/123">