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

不动就问, Nginx rewrite 规则设置问题

  •  
  •   thiszero · 2017-08-29 13:42:03 +08:00 · 2011 次点击
    这是一个创建于 2430 天前的主题,其中的信息可能已经有所发展或是发生改变。

    RT,就是想让不同 useragent 访问不同的静态 html 文件,没有生成的静态文件的话就丢给 index.php ,try_files 上面和下面都用的话 nginx 会报错,rewrite 搞了半天了没搞懂啊,求大神~

    location = / { if ( $http_user_agent ~* "mobile" ) { rewrite ^.+ /html/index-mobile.html $uri $uri/ /index.php?$args ; } try_files /html/index.html $uri $uri/ /index.php?$args ; }

    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1602 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:00 · PVG 01:00 · LAX 10:00 · JFK 13:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.