timmah1 Posted July 17, 2009 Share Posted July 17, 2009 I'm sure this is simple I know this $_SERVER['HTTP_REFERER'] shows the link the user came from, including sub directories and pages I know this $_SERVER['HTTP_HOST'] shows the host How do I combine the two to show just the host of the referer link? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/166329-solved-referer-links/ Share on other sites More sharing options...
Nix Posted July 17, 2009 Share Posted July 17, 2009 Not sure I got your point, but try with this: <?php $referer = preg_replace("/(http:\/\/(.*)\/)[\S]*/", "\\1", $_SERVER['HTTP_REFERER']); $name = preg_replace("/http:\/\//", "", $referer); echo $name; ?> Link to comment https://forums.phpfreaks.com/topic/166329-solved-referer-links/#findComment-877084 Share on other sites More sharing options...
WolfRage Posted July 17, 2009 Share Posted July 17, 2009 HTTP_HOST refers to you or your domain as the host not the referer as a host. Link to comment https://forums.phpfreaks.com/topic/166329-solved-referer-links/#findComment-877085 Share on other sites More sharing options...
timmah1 Posted July 17, 2009 Author Share Posted July 17, 2009 Nix, that works just like I need it to I better clarify what I needed. Let's say a referral link is http://www.test.com/banners/mybanner.php I would like to just show http://www.test.com Thanks for the help Nix Link to comment https://forums.phpfreaks.com/topic/166329-solved-referer-links/#findComment-877088 Share on other sites More sharing options...
Nix Posted July 17, 2009 Share Posted July 17, 2009 No worries! Glad that helped Cheers! Link to comment https://forums.phpfreaks.com/topic/166329-solved-referer-links/#findComment-877090 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.