Php 如何根据推荐人重定向和/或延迟?
我想只允许从某个引用URL(如“example.com/123”)访问我的网站。我想在一个特定的延迟后,比如说1或2分钟,将其余的流量重定向到同一个引用URL。我想要交通 这来自example.com/123,不再提及 我曾想过使用类似的东西,但我不知道如何编辑以满足我的要求: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
<?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">