It is a good solution to automatically determine the code to redirect to the branch based on the IP address, which can alleviate some problems such as excessive server pressure. Function getIpvalue(clientIP)' gets the client's IP and converts it into a long integer, and returns the value getIpvalue
On Error Resume Next
Dim strIp, array_Ip
strIp=0
array_Ip = Split(clientIP,.)
If UBound(array_Ip)<>3 Then
getIpvalue=0
Exit Function
End If
For i=0 To 3
strIp=strIp+(CInt(array_Ip(i))*(256^(3-i)))
Next
getIpvalue=strIp
If Err Then getIpvalue=0
End Function
clientIP=request.ServerVariables(REMOTE_HOST)
IpValue=getIpvalue(clientIP)
strSql=select top 1 City from [Ipaddress] where &IpValue&
between Ip1 and Ip2
Set RsIp=conn.execute(strSql)
If RsIp.bof and RsIp.eof then
UrlCity=Unknown
Else
UrlCity=RsIp.Fields.Item(City).Value
End If
if instr(UrlCity,Guangzhou)<>0 then
response.Redirect(http://www.vevb.com)
end if
if instr(UrlCity,Shenzhen)<>0 then
response.Redirect(http://js.vevb.com)
end if
if instr(UrlCity,Shanghai)<>0 then
response.Redirect(http://tool.vevb.com)
end if
The IP database used can be downloaded online.