文章詳情頁
asp限制域名訪問實現(xiàn)代碼
瀏覽:40日期:2022-06-04 17:04:27
asp 設(shè)置只能指定域名可以使用此網(wǎng)站
代碼一 原創(chuàng)
<% myIp = ",127.0.0.1,localhost,www.jb51.net," 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.jb51.net/" 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獲取當前域名和端口號方法
asp獲取當前域名從來就不是什么有難度的事情,但是在實際項目使用中,大家獲取的具體URL信息可能是不同的,各個方法獲取見下表,而如果要獲取當前域名,可以看下面加粗部分:
Request.ServerVariables("SERVER_NAME")"當前域名
Request.ServerVariables("SERVER_PORT")"當前端口
Request.ServerVariables("SCRIPT_NAME")"當前文件名
Request.ServerVariables("QUERY_STRING")"當前頁面的傳入?yún)?shù)
Request.ServerVariables("HTTP_USER_AGENT")"取得當前瀏覽器信息
Request("remote_addr")"取得IP
Request.ServerVariables("HTTP_REFERER")"上個頁面地址
Request.ServerVariables("HTTP_HOST")"獲取當前域名
當采用SERVER_NAME時返回的是不帶端口號的URL
標簽:
ASP
相關(guān)文章:
1. ASP基礎(chǔ)知識VBScript基本元素講解2. ajax請求添加自定義header參數(shù)代碼3. Python requests庫參數(shù)提交的注意事項總結(jié)4. IntelliJ IDEA導(dǎo)入jar包的方法5. Kotlin + Flow 實現(xiàn)Android 應(yīng)用初始化任務(wù)啟動庫6. 詳談ajax返回數(shù)據(jù)成功 卻進入error的方法7. 使用Python和百度語音識別生成視頻字幕的實現(xiàn)8. 使用python 計算百分位數(shù)實現(xiàn)數(shù)據(jù)分箱代碼9. python操作mysql、excel、pdf的示例10. vue-electron中修改表格內(nèi)容并修改樣式
排行榜
