I have $_SERVER[\'HTTP_REFERER\'] — pretend it is http://example.com/i/like/turtles.html. What would I need to do to get just the http://example.com
$_SERVER[\'HTTP_REFERER\']
http://example.com
You could use a regular expression:
if (isset($_SERVER['HTTP_REFERER']) && preg_match('@^[^/]+://[^/]+@', $_SERVER['HTTP_REFERER'], $match)) { var_dump($match[0]); }
Or you could use the parse_url function.