Code: Select all
$referer = basename($_SERVER['HTTP_REFERER']);So if the referer is http://www.example.com/example1 the script would echo example.com.
I also want to match the domain string of the referer to $_SERVER['HTTP_HOST'] (current domain name). This would let me avoid having to fill in the domain name as a variable when porting the script to other projects.
I've tried something along the following...
Code: Select all
$domain = $_SERVER['HTTP_HOST'];
$referer = $_SERVER['HTTP_REFERER'];
if ($referer == $domain) {}