有时候我么您需要获取网址,端口、路径文件名、参数等,这里就为大家分享一下这个函数代码,需要的朋友可以参考下
函数1
<% 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
<!--获取当前页面路径--> <% 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页面
<script> var pathname = window.location.pathname; location.replace("/do.asp?p="+pathname); </script>
将路径传参给do.asp进行处理
strpath=Request("p")
即可获取404之前的页面,然后进行执行操作即可,注意目录权限。也可以放到404中处罚iframe进行操作。
免责声明:本站发布的内容(图片、视频和文字)以原创、来自互联网转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:ts@56dr.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
Copyright © 2009-2021 56dr.com. All Rights Reserved. 特网科技 版权所有 珠海市特网科技有限公司 粤ICP备16109289号
域名注册服务机构:阿里云计算有限公司(万网) 域名服务机构:烟台帝思普网络科技有限公司(DNSPod) CDN服务:阿里云计算有限公司 中国互联网举报中心 增值电信业务经营许可证B2 建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站