I have a client. Let's say their domain is www.mydomain.com.
We are creating a new page at www.mydomain.com/newsection.
On the /newsection page, the client would like to add a link that says "Go back to main site" (www.mydomain.com) ONLY if the user was previously on the main site before.
So, I set up a code snippet of PHP like this:
<?php
$referral = $_SERVER['HTTP_REFERER'];
if (preg_match('/http://www.mydomain.com/', $referral)) {
echo "from My Domain";
} else {
echo "not from My Domain";
}
?>
However, this always returns false ("Not from My Domain"), even if the user is coming from mydomain.com.
Are there any obvious syntax errors or other logic issues that I'm not getting?
Is the issue that my new page (www.mydomain.com/newsection) is still on that main domain?