header('host'); $url = preg_match("/^(https|http):\/\//", trim($url,'//')) ? $url : '//'.$host . '/' . ltrim($url, '/'); } $url = $url? preg_replace("/^(https|http):\/\//", '//', $url) : ''; if(preg_match("/127.0|localhost/", $host) && $url){ $url = preg_replace("/^\/\//", 'http://', $url); } return $url; } }