Mad*_*ddy 10 vbscript asp-classic
我正在研究经典的asp应用程序.我在某些页面上使用了URL重写.
如何在经典asp中获取页面的当前URL?
例如:http: //www.site.com/page.asp --->在IIS中重写url ---> http://www.site.com/home/page
所以在这里我想要的网页的当前网址是http://www.site.com/home/page
请帮我.谢谢.
Kon*_*rad 20
没有花哨的功能可以完成所有工作.
首先,你需要获得协议(如果它不总是http):
Dim protocol
Dim domainName
Dim fileName
Dim queryString
Dim url
protocol = "http"
If lcase(request.ServerVariables("HTTPS"))<> "off" Then
protocol = "https"
End If
Run Code Online (Sandbox Code Playgroud)
现在剩下的可选查询字符串:
domainName= Request.ServerVariables("SERVER_NAME")
fileName= Request.ServerVariables("SCRIPT_NAME")
queryString= Request.ServerVariables("QUERY_STRING")
url = protocol & "://" & domainName & fileName
If Len(queryString)<>0 Then
url = url & "?" & queryString
End If
Run Code Online (Sandbox Code Playgroud)
希望对你有效.
gpi*_*kas 17
您可以尝试输出所有ServerVariables,如下所示:
for each key in Request.Servervariables
Response.Write key & " = " & Request.Servervariables(key) & "<br>"
next
Run Code Online (Sandbox Code Playgroud)
也许您寻找的网址已经存在.我们使用Rewrite模块,并且调用的ServerVariable HTTP_X_ORIGINAL_URL
包含重写的URL路径,例如示例中的"/ home/page".
Protocol(HTTPS=ON/OFF
)和Server(SERVER_NAME
)也可以在ServerVariables中找到.
归档时间: |
|
查看次数: |
28788 次 |
最近记录: |