Get and match referer domain name to referer?
Posted: Tue Mar 13, 2007 4:58 pm
This gets the file name...
Though I would like to get the domain name alone instead of the file name.
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...
But again I need to figure out how to get the domain name out of the referer first. Thanks!
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) {}