I am trying to redirect users on my site that come from a certian referal site to have a special message. I have this:
<?php $REFERER = $_SERVER['HTTP_REFERER'];
if ($REFERER == "http://www.url.com/") {
?>
Content Goes Here
?>
}
?>
And they do not get the message
I did a test and did it from one of my other sites and echoed what the $_SERVER['HTTP_REFERER'];
put out and changed the above code to match it exactly and it worked but I think the issue I am having is the output of the $_SERVER['HTTP_REFERER'];
is not EXACTLY the same. For instance if they were on the page www.domain.com/page2/index.php
the referrer would be http://www.domain.com/page2/
is there a way to make it so people that come from www.domain.com no matter whats after the / ?!?
UPDATE:
I tried all the first 2 answers and could not get it to work (possibly my fault) so i did some research from what they sent and created this:
<?php
$mystring = $_SERVER['HTTP_REFERER'];
$findme = 'domain';
$pos = strpos($mystring, $findme);
if ($pos === false) {
} else {
echo "content";
?>
Is there anything wrong with this option as it seems to work?
A real simple one would be:
You can use php's
parse_url
function:You can check if the string starts with
http://www.url.com/