Copy Code code as follows:
<%
String wap = "http://3g.ssss.com.cn";
String Agent = Request.getheader ("user-agent");
String Agent = "mozilla/5.0" (Macintosh; Intel Mac OS X 10_7_2) applewebkit/534.51.22 (khtml, like Gecko) version/5.1.1 safari/534.51.22 ";
String Agentcheck = Agent.trim (). toLowerCase ();
Boolean iswap = false;
string[] keywords = {"mobile", "Android",
"SymbianOS", "iphone", "wp\\d*", "Windows Phone",
"Mqqbrowser", "Nokia", "Samsung", "Midp-2",
"untrusted/1.0", "Windows CE", "blackberry", "UCWeb",
"Brew", "J2ME", "Yulong", "Coolpad", "Tianyu", "ty-",
"K-touch", "Haier", "Dopod", "Lenovo", "Huaqin", "aigo-",
"ctc/1.0", "ctc/2.0", "CMCC", "Daxian", "mot-",
"SonyEricsson", "Gionee", "HTC", "ZTE", "Huawei", "webOS",
"Gobrowser", "Iemobile", "wap2.0", "WAPI"};
Pattern PF = pattern.compile ("wp\\d*");
Matcher MF = pf.matcher (Agentcheck);
if (agentcheck!=null&& (Agentcheck.indexof ("Windows NT") = = 1 && agentcheck
. IndexOf ("Ubuntu") = = 1)
|| (Agentcheck.indexof ("Windows NT") >-1 && mf.find ()) {
for (int i = 0; i < keywords.length; i++) {
Pattern p = pattern.compile (keywords[i]);
Matcher m = P.matcher (Agentcheck);
Excluding Apple desktop system and ipad, ipod
if (M.find () && agentcheck.indexof ("ipad") = = 1
&& agentcheck.indexof ("ipod") = = 1
&& agentcheck.indexof ("macintosh") = = 1) {
Iswap = true;
Break
}
}
}
if (Iswap) {
Response.sendredirect (WAP);
}
%>
Copy Code code as follows:
/** Mobile Browser User-agent in the keyword * *
"Nokia",//Nokia, there are Shanzhai machine also write this, total still is mobile phone, mozilla/5.0 (Nokia5800 XpressMusic) UC AppleWebKit (like Gecko) safari/530
"Samsung",//Samsung mobile phone samsung-gt-b7722/1.0+shp/vpp/r5+dolfin/1.5+nextreaming+smm-mms/1.2.0+profile/midp-2.1+ configuration/cldc-1.1
"MIDP-2",//j2me2.0,mozilla/5.0 (symbianos/9.3; U series60/3.2 nokiae75-1/110.48.125 profile/midp-2.1 configuration/cldc-1.1) applewebkit/413 (KHTML like Gecko) Safari/ 413
"CLDC1.1",//m600/midp2.0/cldc1.1/screen-240x320
"SymbianOS",//Symbian system,
"MAUI",//MTK Cottage machine Default UA
"untrusted/1.0",//suspected cottage machine UA, basic can be sure or mobile phone
"Windows CE",//windows ce,mozilla/4.0 (compatible; MSIE 6.0; Windows CE; Iemobile 7.11)
"IPhone", does//iphone also turn WAP? Whatever it is, tell it first. mozilla/5.0 (IPhone; U CPU iPhone os 4_1 like Mac os X; ZH-CN) applewebkit/532.9 (khtml like Gecko) mobile/8b117
"ipad",//ipad's ua,mozilla/5.0 (ipad; U CPU os 3_2 like Mac os X; ZH-CN) applewebkit/531.21.10 (khtml like Gecko) version/4.0.4 mobile/7b367 safari/531.21.10
"Android", does//android also turn WAP? mozilla/5.0 (Linux; U Android 2.1-update1; ZH-CN; XT800 build/tita_m2_16.22.7) applewebkit/530.17 (khtml like Gecko) version/4.0 Mobile safari/530.17
"BlackBerry,"//blackberry8310/2.7.0.106-4.5.0.182.
"UCWEB",//ucweb whether only to the WAP page? Nokia5800 xpressmusic/ucweb7.5.0.66/50/999
"UCWeb",//lowercase ucweb seems to be UC Proxy server mozilla/6.0 (compatible; MSIE 6.0;) Opera Ucweb-squid
"BREW",//Very strange UA, for example: rew-applet/0x20068888 (brew/3.1.5.20; deviceid:40105; LANG:ZHCN) Ucweb-squid
"J2ME",//Very strange UA, only j2me four letters
"Yulong",//Yulong mobile phone, yulong-coolpadn68/10.14 ipanel/2.0 ctc/1.0
"Yulong",//or Yulong
"Coolpad",//Yulong cool faction yl-coolpads100/08.10.s100 polaris/2.9 ctc/1.0
"Tianyu",//day language mobile phone tianyu-ktouch/v209/midp2.0/cldc1.1/screen-240x320
"ty-",//day language, ty-f6229/701116_6215_v0230 jupitor/2.2 ctc/1.0
"K-touch",//or k-touch_n2200_cmcc/tbg110022_1223_v0801 mtk/6223 release/30.07.2008 browser/wap2.0
"Haier",//Haier mobile phone, haier-hg-m217_cmcc/3.0 release/12.1.2007 browser/wap2.0
"Dopod",//Dopod mobile phone
"Lenovo",//Lenovo mobile phone, lenovo-p650wg/s100 lmp/lml release/2010.02.22 profile/midp2.0 configuration/cldc1.1
"Lenovo",//Lenovo mobile phone, such as: lenovo-p780/176a
"Huaqin",//Hua Qin mobile phone
"aigo-",//Patriot Incredibly also out of the cell phone, aigo-800c/2.04 tmss-browser/1.0.0 ctc/1.0
"ctc/1.0",//unclear meaning
"ctc/2.0",//unclear meaning
"CMCC",//Mobile custom mobile phone, k-touch_n2200_cmcc/tbg110022_1223_v0801 mtk/6223 release/30.07.2008 browser/wap2.0
"Daxian",//BIG display mobile phone Daxian X180 up. browser/6.2.3.2 (GUI) mmp/2.0
"mot-",//Motorola, mot-motorokre6/1.0 linuxos/2.4.20 release/8.4.2006 browser/opera8.00 profile/midp2.0 CLDC1.1 software/r533_g_11.10.54r
"SonyEricsson",//Sony Ericsson mobile phone, sonyericssonp990i/r100 mozilla/4.0 (compatible; MSIE 6.0; Symbian OS; 405) Opera 8.65 [ZH-CN]
"Gionee",//Kim Li Mobile
"HTC",//HTC mobile phone
"ZTE",//ZTE mobile phone, zte-a211/p109a2v1.0.0/wap2.0 profile
"The Huawei",/
"WebOS",//palm mobile phone, mozilla/5.0 (webos/1.4.5; U ZH-CN) applewebkit/532.2 (khtml like Gecko) version/1.0 safari/532.2 pre/1.0
"Gobrowser",//3g gobrowser.user-agent=nokia5230/gobrowser/2.0.290 Safari
"Iemobile",//windows CE mobile phone with its own browser,
"WAP2.0"//Support WAP 2.0
"WAPI"//Is the Chinese standard in order to fight WiFi (WiFi is not allowed to use, the licensed function has been castrated, only the parallel mobile phone has this function) is a wireless LAN
Common Smart Machine User agent String
mozilla/5.0 (IPod; U CPU iPhone os 4_3_2 like Mac os X; ZH-CN) applewebkit/533.17.9 (khtml, like Gecko) version/5.0.2 Mobile/8h7
mozilla/5.0 (IPhone; U CPU iPhone os 4_3_2 like Mac os X; ZH-CN) applewebkit/533.17.9 (khtml, like Gecko) version/5.0.2 Mobile/8h7
MQQBROWSER/25 (Linux; U 2.3.3; ZH-CN; HTC Desire S build/gri40;480*800)
mozilla/5.0 (Linux; U Android 2.3.3; ZH-CN; htc_desires_s510e build/gri40) applewebkit/533.1 (khtml, like Gecko) version/4.0 Mobile safari/533.1
mozilla/5.0 (symbianos/9.3; U series60/3.2 nokiae75-1/110.48.125 profile/midp-2.1 configuration/cldc-1.1) applewebkit/413 (KHTML, like Gecko) Safari /413
mozilla/5.0 (IPad; U CPU os 4_3_3 like Mac os X; ZH-CN) applewebkit/533.17.9 (khtml, like Gecko) mobile/8j2
mozilla/5.0 (Windows NT 5.2) applewebkit/534.30 (khtml, like Gecko) chrome/12.0.742.122 safari/534.30
mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) applewebkit/535.1 (khtml, like Gecko) chrome/14.0.835.202 safari/535.1
mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) applewebkit/534.51.22 (khtml, like Gecko) version/5.1.1 safari/534.51.22
mozilla/5.0 (IPhone; CPU iPhone os 5_0 like Mac os X applewebkit/534.46 (khtml, like Gecko) version/5.1 mobile/9a5313e
mozilla/5.0 (IPhone; CPU iPhone os 5_0 like Mac os X applewebkit/534.46 (khtml, like Gecko) version/5.1 mobile/9a5313e
mozilla/5.0 (IPhone; CPU iPhone os 5_0 like Mac os X applewebkit/534.46 (khtml, like Gecko) version/5.1 mobile/9a5313e
mozilla/5.0 (Windows NT 6.1) applewebkit/535.1 (khtml, like Gecko) chrome/14.0.835.202 safari/535.1
mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; trident/5.0; iemobile/9.0; SAMSUNG; OMNIA7)----SAMSUNG MP7
mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; trident/5.0; XBLWP7; ZUNEWP7)----HTC MP7
The following is implemented with JavaScript because it involves page statics and all the JavaScript
Copy Code code as follows:
<script type= "Text/javascript" >
function Iswap () {
var agentcheck=navigator.useragent.tolowercase ();
var chesys=true;
var Iswap=false;
var keywords = ["mobile", "Android",
"SymbianOS", "iphone", "Windows Phone",
"Mqqbrowser", "Nokia", "Samsung", "Midp-2",
"untrusted/1.0", "Windows CE", "blackberry", "UCWeb",
"Brew", "J2ME", "Yulong", "Coolpad", "Tianyu", "ty-",
"K-touch", "Haier", "Dopod", "Lenovo", "Huaqin", "aigo-",
"ctc/1.0", "ctc/2.0", "CMCC", "Daxian", "mot-",
"SonyEricsson", "Gionee", "HTC", "ZTE", "Huawei", "webOS",
"Gobrowser", "Iemobile", "wap2.0", "Wapi"];
Excluding windows, Apple and other desktop systems and ipad, ipod
var rekeywords=["Windows", "Windows ME", "Windows XP", "Windows Xp-based", "Windows NT", "Ubuntu", "ipad", "ipod", "Macintosh "];
if (agentcheck!=null) {
for (var i = 0; i < rekeywords.length; i++) {
if (Agentcheck.indexof (Rekeywords[i].tolowercase ()) >-1) {
Chesys=false;
}
}
}
if (Chesys) {
for (var i = 0; i < keywords.length; i++) {
if (Agentcheck.indexof (Keywords[i].tolowercase ()) >-1) {
Iswap = true;
Break
}
}
}
if (Iswap) {
Window.location.href= "http://3g.gf.com.cn";
}
}
</script>