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;