nginx 区分pc和mobile 到不同的404页面

if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry|vivo)') {
set $mobile_request '1';
} = 严格匹配。如果这个查询匹配,那么将停止搜索并立即处理此请求。
~ 为区分大小写匹配(可用正则表达式)
!~为区分大小写不匹配
~* 为不区分大小写匹配(可用正则表达式)
!~*为不区分大小写不匹配
^~ 如果把这个前缀用于一个常规字符串,那么告诉nginx 如果路径匹配那么不测试正则表达式。 121.40.205.143 - - [21/Jun/2016:14:43:37 +0800] "GET /wechat/xx.html HTTP/1.1" 404 17 "-" "Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036524 Safari/537.36 MicroMessenger/6.3.18.800 NetType/WIFI Language/zh_CN"
121.40.205.143 - - [21/Jun/2016:14:43:37 +0800] "GET /wechat/xx.html HTTP/1.1" 404 17 "-" "Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036524 Safari/537.36 MicroMessenger/6.3.18.800 NetType/WIFI Language/zh_CN" location / {
root /var/www/zjzc-web-frontEnd/;
index index.html;
error_page 404 /common/404.html;
if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry|)'){
error_page 404 /common/m404.html;
} 121.40.205.143 - - [21/Jun/2016:14:56:47 +0800] "GET /wechat/yy.html HTTP/1.1" 404 17 "-" "Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036524 Safari/537.36 MicroMessenger/6.3.18.800 NetType/WIFI Language/zh_CN"
121.40.205.143 - - [21/Jun/2016:14:56:47 +0800] "GET /wechat/yy.html HTTP/1.1" 404 17 "-" "Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036524 Safari/537.36 MicroMessenger/6.3.18.800 NetType/WIFI Language/zh_CN" 121.40.205.143 - - [21/Jun/2016:14:57:13 +0800] "GET /wechat/xx.html HTTP/1.1" 404 17 "-" "Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/35.0.1916.138 Mobile Safari/537.36 T7/6.3 baiduboxapp/7.3.1 (Baidu; P1 5.1.1)"
121.40.205.143 - - [21/Jun/2016:14:57:13 +0800] "GET /favicon.ico HTTP/1.1" 404 17 "-" "Mozilla/5.0 (Linux; Android 5.1.1; vivo X6S A Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/35.0.1916.138 Mobile Safari/537.36 T7/6.3"
上一篇:ubuntu12.04下一个samba、tftp、nfs构造


下一篇:SpringBoot MockMvc的单元测试