We need to use this function. How can we test it? Code
Assume that the address is:
Http://dxy.com: 8082/test/geturl. asp? Param-VR52tmx3syn03777.html
Method 1: simple. There is no parameter, and there is only one virtual path.Copy codeThe Code is as follows: geturl = request ("url") ', because we do not have the url = character, we can directly pass it.
Method 2: Obtain the entire URL and obtain the parameters.Copy codeThe Code is 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") <> 80 then strtemp = strtemp & ":" & request. servervariables ("server_port ")
Strtemp = strtemp & request. servervariables ("url ")
If trim (request. querystring) <> "then strtemp = strtemp &"? "& Trim (request. querystring)
Geturl = strtemp
End Function
The Path obtained by testing this code is:
/Test/geturl. asp? Param-VR52tmx3syn03777.html =
Method 2: Obtain the virtual path and obtain the parameters.
Copy code The Code is as follows: Private function geturl ()
Dim scriptaddress, m_itemurl, m_item
Scriptaddress = CSTR (request. servervariables ("script_name") 'gets the 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 'Here, the function is to filter out the page_num page parameters (this parameter is set in page_turn.asp and changed according to personal settings ), otherwise, this parameter will be superimposed on every page turning. Although this parameter does not affect the function, it is always not 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 address obtained from the above Code is
Http://dxy.com: 8082/test/geturl. asp? Param-VR52tmx3syn03777.html
Basically
If you just want to get? We can use the following codeCopy codeThe Code is as follows: Response. Write Replace (request. querystring, ". html ","")
What we get is that the Param-VR52tmx3syn03777 meets our needs.
PS: all the above cases are for pure ASP. If combined with urlrewrite, the functions will be enhanced, and the search will be more friendly.