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 · 2214 views
    This topic created in 2077 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   ·   Solana   ·   5203 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 08:31 · PVG 16:31 · LAX 01:31 · JFK 04:31
    ♥ Do have faith in what you're doing.