Extracting domain part from an url How to get the domain ( i.e www.aspcode.net) part from an URL string

        <%Function DomainFromUrl( sText )
        '
        Dim nIndex
        If LCase(Left( sText, 7 )) = "http://" Then
        sText = Mid( sText, 8 )
        End If
        If LCase(Left( sText, 8 )) = "https://" Then
        sText = Mid( sText, 9 )
        End If
        nIndex = InStr( sText, "/")
        If nIndex > 0 Then
        sText = Left( sText, nIndex - 1 )
        End If
        DomainFromReq = sText
        End Function
Use it like this:
DomainFromURL( "http://www.aspcode.net/default.asp") -> www.aspcode.net 
DomainFromURL( "https://www.aspcode.net") -> www.aspcode.net 
DomainFromURL( "www.aspcode.net/articles/art1/art1,asp") -> www.aspcode.net
Information and tips