nginx 通过user-agent判断是手机的浏览器

nginx 通过user-agent判断是手机的浏览器
来源: http://www.blogjava.net/ann/archive/2009/12/08/305096.html

user-agent 收集:

http://www.developershome.com/wap/detection/detection.asp?page=userAgentHeader

http://search.cpan.org/~cmanley/Mobile-UserAgent-1.05/lib/Mobile/UserAgent.pm

http://www.zytrax.com/tech/web/mobile_ids.html

http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones

nginx

location = / {

root /var/www/path;
if ($http_user_agent ~* "Nokia") { rewrite . /index.html break; }

if ($http_user_agent ~* "Mobile") { rewrite . /index.html break; }

if ($http_user_agent ~* "SAMSUNG") { rewrite . /index.html break; } }

if ($http_user_agent ~* "SonyEricsson") { rewrite . /index.html break; }
if ($http_user_agent ~* "MOT") { rewrite . /index.html break; } }
if ($http_user_agent ~* "BlackBerry") { rewrite . /index.html break; }
if ($http_user_agent ~* "LG") { rewrite . /index.html break; } }
if ($http_user_agent ~* "HTC") { rewrite . /index.html break; }

if ($http_user_agent ~* "J2ME") { rewrite . /index.html break; }
if ($http_user_agent ~* "Opera Mini") { rewrite . /index.html break; } }
index index.html;
}

你可能感兴趣的:(nginx,浏览器,手机,休闲,User-Agent)