nginx只允许移动端访问( 判断拦截pc浏览器访问)

set $mobile_request '0';

if ($http_user_agent ~* (Android|webOS|iPhone|iPod|BlackBerry)) {

set $mobile_request '1';
    }


if ( $request_uri ~* (error)) {

set $mobile_request '2';
    }

if ($mobile_request = '0') {
rewrite ^.+ http://www.baidu.com/error.html;
}

nginx只允许移动端访问( 判断拦截pc浏览器访问)

原文地址:https://www.cnblogs.com/jifeng/p/6954253.html