To handle the URL so that it preserves the URL without a scheme, while allowing you to identify the domain, use the following code.
if (!preg_match('/^([a-z][a-z0-9\-\.\+]*:)|(\/)/', $url)) {
$url = '//' . $url;
}
So, this will apply "//" to the beginning of the URL only if the URL does not have a valid pattern and does not start with "/".
:
() , ":" , , "//", . , URL , , , "://".
[scheme]:[path//path]//[domain][/path][scheme]://[domain][/path][/path][path]
PHP URL- parse_url(), , .
: alpha *( alpha | digit | "+" | "-" | "." )