Nginx 多重判斷

說明:nginx 不支持&& 和嵌套if判斷nginx

   #多重判斷,匹配移動端和http_host爲xxx.com跳轉到m.xxx.comide

   set $flag 0;spa


   if ( $http_user_agent ~ "(iPhone)|(Android)" ) {orm

        set $flag "${flag}1";ci

    }it


   if ( $http_host ~* "^(xxx\.com)$" ) {form

        set $flag "${flag}1";class

   }transform


   if ( $flag = "011" ) {float

        rewrite ^(.*) http://m.xxx.com/;

   }

相關文章
相關標籤/搜索