Reputation: 11
I want to redirect my site visitors form page B using my custom PHP script following this rule: If they come from page A, will be redirected to url 1, else i will display content/or url 2. I use this:
<?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';
}
?>
. Anyone can help?
Upvotes: 1
Views: 98
Reputation: 522
<?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';
}
?>
Instead of meta redirect you can also use header location.
header("Location:http://www.google.com");
Upvotes: 2