2015-06-14 84 views
0

我想使用我的自定义PHP脚本按照此规则重定向我的站点访问者表单页面B:如果它们来自页面A,将被重定向到URL 1,否则我将显示内容/或URL 2.我使用这个:PHP重定向脚本

<?php 
$referer = $_SERVER['HTTP_REFERER']; 
$rest = substr("$referer", -8); 
if($rest == "send.php")// if they come from my website page "send.php" 
{ 
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://google.com\">"; 
} 
else 
{ 
echo "$rest"; 
include 'content.php'; 
} 
?> 

。 任何人都可以提供帮助吗?

+0

为什么你不能使用标题,然后检查? –

回答

1
<?php 
$referer = $_SERVER['HTTP_REFERER']; 
if (strpos($referer,'send.php') !== false) 
{ 
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://google.com\">"; 
} 
else 
{ 
echo "$rest"; 
include 'content.php'; 
} 
?> 

代替元重定向,你也可以使用标题位置。

header("Location:http://www.google.com"); 
+0

Thx,我使用元重定向,因为我想保留引用者。 –