› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
peterzhang0602
V2EX  ›  NGINX

nginx 同一域名根据设备不同切换 root 目录

  •  
  •   peterzhang0602 · Sep 11, 2020 · 2472 views
    This topic created in 2227 days ago, the information mentioned may be changed or developed.

    当切换移动端,就 404,看 nginx 日志请求了 物理路径;

     location / {
                root /usr/share/nginx/html/seller_app_pc/;
                if ( $http_user_agent ~ "(iPhone)|(Android)" ){
                  root /usr/share/nginx/html/seller_app_h5/;
                }
              index index.html;
              try_files $uri $uri/ @router;
            }
           location @router {
            rewrite ^.*$ /index.html last;
        }
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2796 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 04:24 · PVG 12:24 · LAX 21:24 · JFK 00:24
    ♥ Do have faith in what you're doing.