location / {
#pc端內容訪問
set $flag "pc";
set $num 1;
set $hua "${http_user_agent}";
set $iospad "${http_user_agent}";
set $androidpad "${http_user_agent}";html
#mobile端訪問內容
if ( $http_user_agent ~* "Mobile") {
set $flag "mobile";
}android
#ios-pad端訪問內容
if ( $iospad ~* "iPad|ipad") {
set $flag "pad";
}ios
#android-pad端訪問內容
if ( $androidpad ~* "Android") {
set $num "${num}2";
}nginx
if ( $hua !~* "Mobile") {
set $num "${num}3";
}web
if ( $num = "123") {
set $flag "pad";
}學習
root /usr/local/etc/nginx/website/$flag;spa
index index.html index.htm;
}htm
推薦學習文章:https://yq.aliyun.com/articles/44957ip