asp限制域名訪(fǎng)問(wèn)實(shí)現(xiàn)代碼
asp 設(shè)置只能指定域名可以使用此網(wǎng)站
代碼一 腳本之家原創(chuàng)
<%
myIp = ",127.0.0.1,localhost,www.dhdzp.com,"
myurl= request.ServerVariables("SERVER_NAME")
Response.write myurl
if InStr(myIp,","&myurl&",")>0 then
Response.write "域名合法"
else
Response.write "域名不合法"
end if
%>
代碼二
myIp = Array("127.0.0.1","jb51")
myHou = new Array("",".com")
myDirect ="http://www.dhdzp.com/"
ip= request.ServerVariables("HTTP_HOST")
j=0
for i=0 to ubound(myIp)
'Response.Write(i&"--"&myIp(i)&"<br>")
if InStr(ip,myIp(i)&myHou(i))>0 then
'Response.Write(myIp(i)&"==")
j=j+1
end if
next
if j<1 then
response.Redirect(myDirect)
end if
上面的代碼用到了下面的資料
asp獲取當(dāng)前域名和端口號(hào)方法
asp獲取當(dāng)前域名從來(lái)就不是什么有難度的事情,但是在實(shí)際項(xiàng)目使用中,大家獲取的具體URL信息可能是不同的,各個(gè)方法獲取見(jiàn)下表,而如果要獲取當(dāng)前域名,可以看下面加粗部分:
Request.ServerVariables("SERVER_NAME")'當(dāng)前域名
Request.ServerVariables("SERVER_PORT")'當(dāng)前端口
Request.ServerVariables("SCRIPT_NAME")'當(dāng)前文件名
Request.ServerVariables("QUERY_STRING")'當(dāng)前頁(yè)面的傳入?yún)?shù)
Request.ServerVariables("HTTP_USER_AGENT")'取得當(dāng)前瀏覽器信息
Request("remote_addr")'取得IP
Request.ServerVariables("HTTP_REFERER")'上個(gè)頁(yè)面地址
Request.ServerVariables("HTTP_HOST")'獲取當(dāng)前域名
當(dāng)采用SERVER_NAME時(shí)返回的是不帶端口號(hào)的URL
相關(guān)文章
asp動(dòng)態(tài)級(jí)聯(lián)菜單代碼
asp動(dòng)態(tài)級(jí)聯(lián)菜單代碼...2007-03-03
asp獲取當(dāng)前完整路徑(url)的函數(shù)代碼
這篇文章主要介紹了asp獲取當(dāng)前完整路徑(url)的函數(shù)代碼,有時(shí)候我么您需要獲取網(wǎng)址,端口、路徑文件名、參數(shù)等,這里就為大家分享一下這個(gè)函數(shù)代碼,需要的朋友可以參考下2020-02-02
ASP版實(shí)現(xiàn)cookies注入加速工具
ASP版實(shí)現(xiàn)cookies注入加速工具...2007-11-11
ASP下通過(guò)Adodb.Stream實(shí)現(xiàn)多線(xiàn)程下載大文件
這篇文章主要介紹了ASP下通過(guò)Adodb.Stream實(shí)現(xiàn)多線(xiàn)程下載大文件,需要的朋友可以參考下2020-08-08

