V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
peterzhang0602
V2EX  ›  NGINX

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

  •  
  •   peterzhang0602 · 2020-09-11 20:40:39 +08:00 · 1741 次点击
    这是一个创建于 1316 天前的主题,其中的信息可能已经有所发展或是发生改变。

    当切换移动端,就 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;
        }
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2540 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 01:12 · PVG 09:12 · LAX 18:12 · JFK 21:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.