问题描述:
现在根据下面代码已经可以实现根据判断内网外网IP跳转到不同页面
比如外面就直接跳到2.htm,内网就直接跳1.htm
但是外网知道你1.HTM这地址直接打地址就可以访问的.
我应该怎么样在1.htm做限制呢????如果他是外网打1.htm这个地址还是要他
跳会2.htm这个页面呢??
有知道请详细写一下好吗??谢谢..
<%
ipx=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
IF ipx="" Then ipx=Request.ServerVariables("REMOTE_ADDR")
if ipCheck(ipx,"202.116.192.1","202.116.250.254")="true" then
response.Redirect "1.htm"
elseif ipCheck(ipx,"172.16.0.1","172.16.255.254 ")="true" then
response.Redirect "1.htm"
elseif ipCheck(ipx,"192.168.0.1","192.168.255.254 ")="true" then
response.Redirect "1.htm"
else
response.Redirect "2.htm"
end if
function ipCheck(ip,startIp,endIp)
ipPart=split(ip,".")
startIpPart =split(startIp,".")
endIpPart =split(endIp,".")
if ipPart(0)&"."&ipPart(1)=startIpPart(0)&"."&startIpPart(1) then
if ipPart(2)>=startIpPart(2) and ipPart(2)<=endIpPart(2) then
ipCheck="true"
else
ipCheck="false"
end if
else
ipCheck="false"
end if
end function
%>
我知道应该在1.HTM和2.HTM中再检测一次IP,检测到外网就跳转。
但是具体应该是怎么写呀???
不可能把这段直接考到最上面的。
应该怎么在1.htm做检测呢??
请详细写一下好?
问题解答:
1.html里加个验证就行了
ipx=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
IF ipx="" Then ipx=Request.ServerVariables("REMOTE_ADDR")
if not(ipCheck(ipx,"202.116.192.1","202.116.250.254") or ipCheck(ipx,"202.116.192.1","202.116.250.254") or ipCheck(ipx,"202.116.192.1","202.116.250.254")) then
response.redirect("2.html")
再1.HTM和2.HTM中再检测一次IP就是了,检测到外网就跳转。
当然,这时1.HTM和2.HTM就不能再用静态的了,要用ASP动态的了。