IIS detection code Access Web site is PC-side or mobile-side users
The code is as follows
Copy Code
ASP check whether the Web site is PC-side or mobile-end user
The code is as follows
Copy Code
Dim u,b,vSet U=request.servervariables ("Http_user_agent")Set B=new REGEXPSet V=new REGEXPB.pattern= "(Android|bbd+|meego). +mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile| IP (hone|od) |iris|kindle|lge |ma
This article will introduce you to check whether the website is accessed by a pc or a mobile user (iis/asp/c #). I hope this method will be helpful to you.
Check whether the iis Code accesses the website on pc or mobile phone
The Code is as follows:
Copy code
Asp checks whether the website is a pc or mobile user
The Code is as follows:
Copy code
Dim u, B, vSet u = Request. ServerVariables ("HTTP_USER_AGENT ")Set B = new RegExpSet v = new Re
foreign countries to distinguish between PCs and mobile phones, which can be directly used:
Http://detectmobilebrowsers.com/
As Nginx is used in this article, you only need to download the Nginx configuration on the website.
Set $ mobile_rewrite do_not_perform; if ($ http_user_agent ~ * "(Android | bb \ d + | meego ). + mobile | avantgo | bada \/| blackberry | blazer | compal | Eline | fennec | hiptop | iemobile | ip (hone | od) | iris | kindle | lge | maemo | midp | mmp | mobile. + firefox | n
I won't talk about anything else. I just went to the code,JSP Version The code is as follows:Copy code String ua = request. getHeader ("User-Agent"). toLowerCase ();If (ua. matches ("(? I ). * (android | bb \ d + | meego ). + mobile | avantgo | bada \/| blackberry | blazer | compal | Eline | fennec | hiptop | iemobile | ip (hone | od) | iris | kindle | lge | maemo | midp | mmp | netfront | opera m (ob | in) I | palm (OS )? | Phone | p (ixi | re) \/| plucker | pocket | psp
used:
Http://detectmobilebrowsers.com/
As Nginx is used in this article, you only need to download the Nginx configuration on the website.
Set $ mobile_rewrite do_not_perform; if ($ http_user_agent ~ * "(Android | bb \ d + | meego ). + mobile | avantgo | bada \/| blackberry | blazer | compal | Eline | fennec | hiptop | iemobile | ip (hone | od) | iris | kindle | lge | maemo | midp | mmp | mobile. + firefox | netfront | opera m (ob | in) I | palm (OS )? | Phone | p (ixi | re) \/| plucker | pock
and mobile phones, which can be directly used:
Http://detectmobilebrowsers.com/
As Nginx is used in this article, you only need to download the Nginx configuration on the website.
Set $ mobile_rewrite do_not_perform; if ($ http_user_agent ~ * "(Android | bb \ d + | meego ). + mobile | avantgo | bada \/| blackberry | blazer | compal | Eline | fennec | hiptop | iemobile | ip (hone | od) | iris | kindle | lge | maemo | midp | mmp | mobile. + firefox | netfront | opera m (ob | in) I | palm (OS )?
in this article, just to download the Nginx configuration on the site can be.Set $mobile _rewrite do_not_perform;if ($http _user_agent ~* "(android|bb\d+|meego). +mobile|avantgo|bada\/|blackberry |blazer|compal|elaine|fennec|hiptop|iemobile|ip (hone|od) |iris|kindle|lge |maemo|midp|mmp|mobile.+firefox| Netfront|opera m (ob|in) i|palm (OS)? | Phone|p (Ixi|re) \/|plucker|pocket|psp|series (4|6) 0|symbian|treo|up\. (browser|link) |vodafone|wap|windows Ce|xda|xiino ") {set $mobile _rewrite perform;
Python determines whether a website is from a mobile phone or a PC browser #判断网站来自mobile还是pcdef checkmobile (Request): "" "NBSP;NBSP;NBSP;NBSP;DEMONBSP;: @app. Route ('/m ') defis_from_mobile (): if checkmobile (Request): return ' Mobile ' Else:return ' PC ' :p aramrequest::return: "" "useragent=request.headers[' user-agent ']# Useragent=env.get (' http_user_agent ') _long_matches=r ' Googlebot-mobile|android|avantgo|blackBerry|blazer|elaine|hiptop|ip (Hone|od) |kindle|midp|mmp|mobile|o2|ope
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.