// Domain class $server_name = $_SERVER['SERVER_NAME']; $http_host = $_SERVER['HTTP_HOST']; $s = explode('.', $server_name); $h = explode('.', $http_host); preg_match("/^(http:\/\/)?([^\/]+)/i", $http_host, $matches); $host = $matches[2]; // get host name from URL preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); $domain = $matches[0]; // get last two segments of host name if ($server_name !== $domain){$domain_class = $s[0];} ?>