Asp-Classic

如何在 Classic ASP 中獲取目前域?

  • January 12, 2017

我想獲取目前域,所以如果頁面是http://www.domain.com/page.asp我需要www.domain.com

Request.ServerVariables("SERVER_NAME")'

要完整,我的功能之一:

 function PageUrl
    dim sPort
    sPort = Request.ServerVariables("SERVER_PORT")
    if sPort = "80" then
       sPort = ""
    else
       sPort = ":" & sPort
    end if

    PageUrl = "http://" & Request.ServerVariables("SERVER_NAME") & sPort & _
                          Request.ServerVariables("URL") & "?" & _
                          Request.ServerVariables("QUERY_STRING")
 end function

請求伺服器變數之一(server_name?)

http://www.w3schools.com/asp/coll_servervariables.asp

引用自:https://stackoverflow.com/questions/2148952