為了讓客戶端更快速的訪問(wèn)網(wǎng)站,通常一個(gè)大型網(wǎng)站會(huì)有許多分站,所以讓客戶端訪問(wèn)相應(yīng)的分站,會(huì)讓客戶有更好的體驗(yàn),這就要用到根據(jù)客戶端IP地址轉(zhuǎn)向不同的分站。這里面要用到IP數(shù)據(jù)庫(kù),可到網(wǎng)上去下載。IP數(shù)據(jù)庫(kù)在此主要用途是根據(jù)得到的IP,找到此IP所在的地址。 Function getIpvalue(clientIP)'得到客戶端的IP轉(zhuǎn)換成長(zhǎng)整型,返回值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="未知" Else UrlCity=RsIp.Fields.Item("City").Value End If if instr(UrlCity,"廣州")<>0 then response.Redirect("http://code.knowsky.com") end if if instr(UrlCity,"深圳")<>0 then response.Redirect("http://moban.knowsky.com") end if if instr(UrlCity,"上海")<>0 then response.Redirect("http://font.knowsky.com") end if