1. 程式人生 > 其它 >nginx 配置移動端和PC端自動跳轉

nginx 配置移動端和PC端自動跳轉

       location /site {

                gzip on;
                gzip_min_length 1k;
               #gzip_buffers 4 16k;
                gzip_http_version 1.1;
                gzip_comp_level 4;
                gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/gif;
                gzip_vary off;
                gzip_disable "MSIE [1-6]\.";

                set $site_path /html/site/pc/dist/;
                if ($http_user_agent ~ "(Android|webOS|iPhone|iPad|iPod|BlackBerry|opera mini|opera mobile|appleWebkit.*mobile|mobile)"){
                    set $site_path /html/site/mobile/dist/;
                }
          
                alias $site_path;
                index index.html;
 
               if ($request_filename ~* .*\.(?:htm|html)$){
                   add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
               }

        }