Page 1 of 1

$HTTP_REFFERER

Posted: Thu May 12, 2005 2:09 am
by Mr Tech
Lets say this pages linked to my website

domain.com
domain.com/page.php
domain.com/anotherpage.html

Using $HTTP_REFFERER to find that they have sent a click to my website, how do I remove everything after the slash so I can match domain.com with my records?

Posted: Thu May 12, 2005 3:05 am
by lazersam

Code: Select all

$home = "domain.com";

$refer = substr($HTTP_REFERER, 0, strlen($home));

Posted: Thu May 12, 2005 3:17 am
by Wayne
have a look at the parse_url function

Posted: Thu May 12, 2005 3:40 am
by Mr Tech
That substr code seem to return http://www no matter what site links to me...

How would I use the parse_url funcrion?

Posted: Thu May 12, 2005 4:31 am
by phpScott
domain.com/page.php

Code: Select all

$splitUrl = parse_url($HTTP_REFFERS);
echo $splitUrl['host'];
//should echo out domain.com
lots of info in the manual for parse_url