Method 1:
<Script>
If (navigator. platform. indexOf ('win32 ')! =-1 ){
// Pc
// Window. location. href = "computer website ";
} Else {
// Shouji
Window. location. href = "Mobile Website ";
}
</Script>
Method 2:
<Script type = "text/javascript">
Function browserRedirect (){
Var sUserAgent = navigator. userAgent. toLowerCase ();
Var bIsIpad = sUserAgent. match (/ipad/I) = "ipad ";
Var bIsIphoneOs = sUserAgent. match (/iphone OS/I) = "iphone OS ";
Var bIsMidp = sUserAgent. match (/midp/I) = "midp ";
Var bIsUc7 = sUserAgent. match (/rv: 1.2.3.4/I) = "rv: 1.2.3.4 ";
Var bIsUc = sUserAgent. match (/ucweb/I) = "ucweb ";
Var bIsAndroid = sUserAgent. match (/android/I) = "android ";
Var bIsCE = sUserAgent. match (/windows ce/I) = "windows ce ";
Var bIsWM = sUserAgent. match (/windows mobile/I) = "windows mobile ";
If (bIsIpad | bIsIphoneOs | bIsMidp | bIsUc7 | bIsUc | bIsAndroid | bIsCE | bIsWM ){
Window. location. href = 'mobile website address ';
} Else {
Window. location = 'computer website address ';
}
}
BrowserRedirect ();
</Script>
Method 3:
<Script type = "text/javascript">
Var mobileAgent = new Array ("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito ", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire ");
Var browser = navigator. userAgent. toLowerCase ();
Var isMobile = false;
For (var I = 0; I <mobileAgent. length; I ++) {if (browser. indexOf (mobileAgent [I])! =-1) {isMobile = true;
// Alert (mobileAgent [I]);
Location. href = 'mobile web site ';
Break ;}}
</Script>
Method 4:
<? Php
//// Put this section in the cell phone Station
Header ("Cache-Control: no-cache ");
Header ("Pragma: no-cache ");
$ Ua = strtolower ($ _ SERVER ['HTTP _ USER_AGENT ']);
$ Uachar = "/(symbianos | android | Mac OS | ucweb | blackberry)/I ";
If ($ ua! = ''&&! Preg_match ($ uachar, $ ua )){
Echo 'window. location. href = "Computer address ";';
Exit ();
}
?>
<? Php
// Put this section in the website
Header ("Cache-Control: no-cache ");
Header ("Pragma: no-cache ");
$ Ua = strtolower ($ _ SERVER ['HTTP _ USER_AGENT ']);
$ Uachar = "/(symbianos | android | Mac OS | ucweb | blackberry)/I ";
If ($ ua! = ''& Preg_match ($ uachar, $ ua )){
Echo 'window. location. href = "Mobile Address ";';
Exit ();
}
?>
Method 5:
<? Php
Function UserAgent (){
$ User_agent = (! Isset ($ _ SERVER ['HTTP _ USER_AGENT '])? FALSE: $ _ SERVER ['HTTP _ USER_AGENT '];
Return $ user_agent;
}
// Mobile
If (preg_match ("/(iphone | ipod | android)/I", strtolower (UserAgent () AND strstr (strtolower (UserAgent ()), 'webkit ')){
Header ('location: Mobile Address ');
Exit;
} Else if (trim (UserAgent ()) = ''OR preg_match ("/(nokia | sony | ericsson | mot | htc | samsung | sgh | lg | philips | lenovo | ucweb | opera mobi | windows mobile | blackberry) /I ", strtolower (UserAgent ()))){
Header ('location: Mobile Address ');
Exit;
} Else {// PC
Header ("Location: web site ");
}
?>
Method 6: You can also download a file named uaredirect to your website;
(Note: Put uaredirect in Baidu to search for the specific file address)