public static function replace_subdomain($url, $newSubdomain)
    {
        $url = parse_url($url);
        if(substr_count($url['host'], '.') >= 2) {
            $url['host'] = (str_replace(
                substr($url['host'], 0, strpos($url['host'], '.')),
                $newSubdomain,
                $url['host']
            ));
        } else {
            $url['host'] = $newSubdomain.'.'.$url['host'];
        }
        return self::unparse_url($url);
    }