Need to use this function, not how to test it, after the test to give specific code
If the address is:
Http://dxy.com:8082/test/geturl.asp?Param-VR52tmx3syn03777.html
Method One: Simple, no parameters, only one virtual path
Copy Code code as follows:
GetUrl =request ("url") ' This is because we have no url= what the word is, so just pass it off.
Method Two: Get the whole URL, get the parameter
Copy Code code as follows:
' Get the address of the current page
Function GetUrl ()
On Error Resume Next
Dim strtemp
If LCase (Request.ServerVariables ("HTTPS") = "Off" Then
strtemp = "http://"
Else
strtemp = "https://"
End If
strtemp = strtemp & Request.ServerVariables ("SERVER_NAME")
If Request.ServerVariables ("Server_port") <> Then strtemp = strtemp & ":" & Request.ServerVariables ("SER Ver_port ")
strtemp = strtemp & Request.ServerVariables ("URL")
If Trim (request.querystring) <> "" Then strtemp = strtemp & "?" & Trim (Request.QueryString)
GETURL = strtemp
End Function
The path tested by this code is:
/test/geturl.asp? Param-vr52tmx3syn03777.html=
Method Two: Obtains the virtual path, obtains the parameter
Copy Code code as follows:
Private Function GetUrl ()
Dim Scriptaddress,m_itemurl,m_item
scriptaddress = CStr (Request.ServerVariables ("Script_name")) ' Get current address
M_itemurl = ""
If (Request.QueryString <> "") Then
scriptaddress = scriptaddress & "?"
For each m_item in Request.QueryString
If M_item = "Page_num" Then Exit for ' The function here is to filter out the parameters of this page of Page_num (this parameter is set by itself in the page_turn.asp, depending on the individual settings), otherwise each page will overlay this parameter, Although it does not affect the function, but it is not very good
If InStr (page,m_item) =0 Then
M_itemurl = M_itemurl & m_item & "=" & Server.URLEncode (Request.QueryString ("" &M_Item& ""))
Else
M_itemurl = M_itemurl & m_item & "=" & Server.URLEncode (Request.QueryString ("" &M_Item& ")) &" & "
End If
Next
Else
scriptaddress = scriptaddress & "?"
End If
GETURL = scriptaddress & M_itemurl
End Function
The above code gets the address
Http://dxy.com:8082/test/geturl.asp?Param-VR52tmx3syn03777.html
Basically, almost.
If just to get the thing behind the number, we can use the following code
Copy Code code as follows:
Response.Write Replace (Request.QueryString, ". html", "")
The only thing we get is param-vr52tmx3syn03777, does it satisfy our needs?
PS: All the above situation is only for pure ASP, if combined with urlrewrite, the function will be enhanced, search friendly type, will also strengthen