有时候我么您需要获取网址,端口、路径文件名、参数等,这里就为大家分享一下这个函数代码,需要的朋友可以参考下
函数1
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<% 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 response.write GetUrl() %>
函数2
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14<!--获取当前页面路径--> <% dim str,host,url,keyword,full str="http://"; host = Request.ServerVariables("HTTP_HOST") url = Request.ServerVariables("PATH_INFO") '或url keyword = Request.ServerVariables("QUERY_STRING") if keyword <> "" then full = str&host&url&"?"&keyword else full = str&host&url end if session("url")=full %>
使用的话肯定选择第一个,支持https的判断。
如果是通过404页面除非,这个是获取不到的,需要结合js来实现
例如:
js页面
复制代码
1
2
3
4<script> var pathname = window.location.pathname; location.replace("/do.asp?p="+pathname); </script>
将路径传参给do.asp进行处理
strpath=Request("p")
即可获取404之前的页面,然后进行执行操作即可,注意目录权限。也可以放到404中处罚iframe进行操作。
最后
以上就是炙热宝贝最近收集整理的关于asp获取当前完整路径(url)的函数代码的全部内容,更多相关asp获取当前完整路径(url)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复