Asp-Classic
經典 ASP - 獲取完整的 url 名稱
我想知道是否有人可以幫助我。
我有以下網址(這是動態的)
www.website.com/images/gal/boxes-pic004.asp如何使用經典 ASP 提取“boxes-pic004”部分
謝謝
<% Dim sScriptLocation, sScriptName, iScriptLength, iLastSlash sScriptLocation = Request.ServerVariables("URL") iLastSlash = InStrRev(sScriptLocation, "/") iScriptLength = Len(sScriptLocation) sScriptName = Right(sScriptLocation, iScriptLength - iLastSlash) %>
sScriptName然後將包含boxes-pic004.asp,然後您也可以使用Replace(sScriptName, ".asp", "")刪除副檔名。
只是您可以嘗試輸出所有ServerVariables,例如,
例如頁面網址: https ://www.google.com/gmail/inbox.asp?uid=1421&skyid=2823595
Dim strProtocol Dim strDomain Dim strPath Dim strQueryString Dim strFullUrl If lcase(Request.ServerVariables("HTTPS")) = "on" Then strProtocol = "https" Else strProtocol = "http" End If strDomain= Request.ServerVariables("SERVER_NAME") strPath= Request.ServerVariables("SCRIPT_NAME") strQueryString= Request.ServerVariables("QUERY_STRING") strFullUrl = strProtocol & "://" & strDomain & strPath If Len(strQueryString) > 0 Then strFullUrl = strFullUrl & "?" & strQueryString End If Response.Write "Domain : " & strDomain & "</br>" Response.Write "Path : " & strPath & "</br>" Response.Write "QueryString : " & strQueryString & "</br>" Response.Write "FullUrl : " & strFullUrl & "</br>"輸出:
Domain : www.google.com Path : /gmail/inbox.asp QueryString : uid=1421&skyid=2823595 FullUrl : https://www.google.com/gmail/inbox.asp?uid=1421&skyid=2823595