ASP needs to use this function to get the current URL, or get all the parameters of the current page. I haven't tested it very much. I will give you the specific code after testing.
If the address is:
http://dxy.com:8082/test/geturl.asp?Param-VR52tmx3syn03777.html
Method 1: Simple, no parameters, only a virtual path
Copy the code code as follows:
GetUrl =request(url) 'Because we don't have the word url=, we can pass it directly.
Method 2: Get the entire URL and get the parameters
Copy the 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) <> 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
After testing this code, the path obtained is:
/test/geturl.asp?Param-VR52tmx3syn03777.html=
Method 2: Get the virtual path and get the parameters
Copy the code code as follows:
Private Function GetUrl()
Dim ScriptAddress,M_ItemUrl,M_item
ScriptAddress = CStr(Request.ServerVariables(SCRIPT_NAME)) 'Get 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 'The function here is to filter out the parameters of Page_num (this parameter is set by itself in page_turn.asp and changes according to personal settings), otherwise this will be superimposed every time the page is turned. Although the parameters do not affect the function, they are still 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 by the above code is
http://dxy.com:8082/test/geturl.asp?Param-VR52tmx3syn03777.html
Basically the same
If we just want to get the thing after the ? number, we can use the following code
Copy the code code as follows:
response.write replace(request.querystring,.html,)
What we get is Param-VR52tmx3syn03777. Does it meet our needs?
PS: All the above situations are only for pure ASP. If combined with urlrewrite, the functions will be enhanced, and the search friendliness will also be enhanced.