手机wap,wap2(xhtml),电脑自适应进入网站asp版
<%
htm = "http://www.rolandlau.com/index.html"
wap = "http://wap.rolandlau.com/index.wml"
wap2 = "http://www.rolandlau.com/index.htm"
agent=request.ServerVariables("HTTP_USER_AGENT")
Accept = request.ServerVariables("HTTP_ACCEPT")
isWAP = false
if (Instr(ucase(Accept),ucase("wap")) or Instr(ucase(Accept),ucase("wml"))) then
isWAP = true
else
brow = left(agent,4)
if (ucase(brow)=ucase("Noki") or ucase(brow)=ucase("Eric") or ucase(brow)=ucase("R380") or ucase(brow)=ucase("MOT-") or ucase(brow)=ucase("UPG1") or ucase(brow)=ucase("Jing") or ucase(brow)=ucase("Acoo") or ucase(brow)=ucase("Wapt") or ucase(brow)=ucase("QWAP") or ucase(brow)=ucase("m-cr") or ucase(brow)=ucase("MC21") or ucase(brow)=ucase("Your") or ucase(brow)=ucase("YOUR") or ucase(brow)=ucase("w@pS") or ucase(brow)=ucase("Alca") or ucase(brow)=ucase("wapw") or ucase(brow)=ucase("Rain") or ucase(brow)=ucase("Java") or ucase(brow)=ucase("AUR ") or ucase(brow)=ucase("UP.B") or ucase(brow)=ucase("WAPm") or ucase(brow)=ucase("WinW") or ucase(brow)=ucase("WapI") or ucase(brow)=ucase("WAPJ") or ucase(brow)=ucase("WapV") or ucase(brow)=ucase("4thp") or ucase(brow)=ucase("Waps") or ucase(brow)=ucase("Mits") or ucase(brow)=ucase("SIE-") or ucase(brow)=ucase("Aptu") or ucase(brow)=ucase("WmlS") or ucase(brow)=ucase("Wapa")) then
isWAP = true
end if
end if
isWAP2 = false
if (isWAP) then
if (Instr(ucase(Accept),ucase("xhtml"))) then
isWAP2 = true
end if
end if
if (isWAP2) then
response.Redirect(wap2)
elseif (isWAP) then
response.Redirect(wap)
else
response.Redirect(htm)
end if
%>
<p>本页没有跳转,请手工选择您的线路</p>
<a href="http://wap.rolandlau.com/index.wml">低端手机wap</a><a href="http://www.rolandlau.com/index.htm">高端手机xhtml</a><a href="http://www.rolandlau.com/index.html">电脑访问</a>
php版
<?php
$htm = "http://www.rolandlau.com/index.html";
$wap = "http://wap.rolandlau.com/index.wml";
$wap2 = "http://www.rolandlau.com/index.htm";
$agent=$_SERVER['HTTP_USER_AGENT'];
$Accept = $_SERVER["HTTP_ACCEPT"];
echo $agent;
$isWAP = false;
if (substr_count(strtolower($Accept),strtolower("wap")) || substr_count(strtolower($Accept),strtolower("wml"))) {
$isWAP = true;
}else{
$brow = substr($agent,0,4);
if (strtolower($brow)==strtolower("Noki") || strtolower($brow)==strtolower("Eric") || strtolower($brow)==strtolower("R380") || strtolower($brow)==strtolower("MOT-") || strtolower($brow)==strtolower("UPG1") || strtolower($brow)==strtolower("Jing") || strtolower($brow)==strtolower("Acoo") || strtolower($brow)==strtolower("Wapt") || strtolower($brow)==strtolower("QWAP") || strtolower($brow)==strtolower("m-cr") || strtolower($brow)==strtolower("MC21") || strtolower($brow)==strtolower("Your") || strtolower($brow)==strtolower("YOUR") || strtolower($brow)==strtolower("w@pS") || strtolower($brow)==strtolower("Alca") || strtolower($brow)==strtolower("wapw") || strtolower($brow)==strtolower("Rain") || strtolower($brow)==strtolower("Java") || strtolower($brow)==strtolower("AUR ") || strtolower($brow)==strtolower("UP.B") || strtolower($brow)==strtolower("WAPm") || strtolower($brow)==strtolower("WinW") || strtolower($brow)==strtolower("WapI") || strtolower($brow)==strtolower("WAPJ") || strtolower($brow)==strtolower("WapV") || strtolower($brow)==strtolower("4thp") || strtolower($brow)==strtolower("Waps") || strtolower($brow)==strtolower("Mits") || strtolower($brow)==strtolower("SIE-") || strtolower($brow)==strtolower("Aptu") || strtolower($brow)==strtolower("WmlS") || strtolower($brow)==strtolower("Wapa")) {
$isWAP = true;
}}
$isWAP2 = false;
if ($isWAP) {
if (substr_count(strtolower($Accept),strtolower("xhtml"))) {
$isWAP2 = true;
}}
if ($isWAP2) {
header("location:$wap2");}
else if ($isWAP) {
header("location:$wap");}
else {
header("location:$htm");
}
?>
<p>本页没有跳转,请手工选择您的线路</p>
<a href="http://wap.rolandlau.com/index.wml">低端手机wap</a><a href="http://www.rolandlau.com/index.htm">高端手机xhtml</a><a href="http://www.rolandlau.com/index.html">电脑访问</a>
JSP版
<%
String htm = "/gas/index.html";
String wap = "/wap/index.wml";
String wap2 = "/wap2/index.xhtml";
String agent = request.getHeader("user-agent");
String accep = request.getHeader("accept");
boolean isWAP = false;
if (accep.toLowerCase().indexOf("vnd.wap.wml")>0){
isWAP = true;
}else{
String brow = agent.substring(0,4);
if (
brow.equals("Noki") ||
brow.equals("Eric") ||
brow.equals("R380") ||
brow.equals("MOT-") ||
brow.equals("UPG1") ||
brow.equals("Jing") ||
brow.equals("Acoo") ||
brow.equals("Wapt") ||
brow.equals("QWAP") ||
brow.equals("m-cr") ||
brow.equals("MC21") ||
brow.equals("Your") ||
brow.equals("YOUR") ||
brow.equals("w@pS") ||
brow.equals("Alca") ||
brow.equals("wapw") ||
brow.equals("Rain") ||
brow.equals("Java") ||
brow.equals("AUR ") ||
brow.equals("UP.B") ||
brow.equals("WAPm") ||
brow.equals("WinW") ||
brow.equals("WapI") ||
brow.equals("WAPJ") ||
brow.equals("WapV") ||
brow.equals("4thp") ||
brow.equals("Waps") ||
brow.equals("Mits") ||
brow.equals("SIE-") ||
brow.equals("Aptu") ||
brow.equals("WmlS") ||
brow.equals("Wapa")){
isWAP = true;
}
}
boolean isWAP2 = false;
if (isWAP){
if (accep.toLowerCase().indexOf("xhtml")>0){
isWAP2 = true;
}
}
if (isWAP2){
response.sendRedirect(wap2);
}else if (isWAP){
response.sendRedirect(wap);
}else{
response.sendRedirect(htm);
}
%>