› 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 · 2425 views
    This topic created in 2209 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   ·   4996 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 06:32 · PVG 14:32 · LAX 23:32 · JFK 02:32
    ♥ Do have faith in what you're doing.