preg_match 只允许 https:// 在 URL

preg_match to only allow https:// in an URL

我想只允许 https:// 链接用作 phpbb 中的远程头像图像,以避免混合内容。这似乎是用来检查输入的url是否正确的代码(在/phpbb/avatar/driver/remote.php中找到):

if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url))
{
    $error[] = 'AVATAR_URL_INVALID';
    return false;
}

我想在此代码块之前添加一个 if{} 条件,以便在用户从非安全服务器中选择图像时提供信息性错误消息。谁能帮我定义正确的 preg_match() 字符串?

根据@casimir 的建议,我使用了以下代码并且有效:

    $urlchk = parse_url($url);
    $urlscheme = isset($urlchk['scheme']) ? $urlchk['scheme'].'://' : 'http://';
    if ($urlscheme=='http://'){
        // error message
    }