Extract hostname from HTTP REFERRER

From Code Trash
Jump to: navigation, search

I created an affiliate system where the main site is included using frame by other sites.
So i need to track them by getting their hostnames without www and i used the following code.
I am not sure whether it has any drawbacks yet i used once and then the module got dropped so this is still under experimentation.


	$REF = $_SERVER['HTTP_REFERER'];
	preg_match("/http:\/\/(.*?)(\/|$)/",$REF,$ref);
	$ref = str_replace('www.','',$ref[1]);