Though this is a very old question, I suspect what Hoque is asking for is everything before the page. For instance, if the URL is http://www.example.com/subsite/default.asp?a=1&b=2
, the expected return value would be http://www.example.com/subsite
.
Function GetSitePath()
Dim address, port, url
address = "http://"
If LCase(Request.ServerVariables("HTTPS")) = "off" Then address = "https://"
address = address & Request.ServerVariables("SERVER_NAME")
port = Request.ServerVariables("SERVER_PORT")
If port <> 80 And port <> 443 Then address = address & ":" & port
url = Request.ServerVariables("URL")
address = address & Left(url, InstrRev(url, "/"))
GetSitePath = address
End Function
Note that I've included no error checking here, to prevent bad URLs, but if this causes an error I would suspect there's something a little more desperate going on!