【问题标题】:NGINX rewrite for static dirNGINX 重写静态目录
【发布时间】:2010-06-09 12:39:11
【问题描述】:

我正在尝试翻译:

mydomain.com/98387634/image/file.png

到:

mydomain.com/image/file.png

谁能告诉我我的重写出了什么问题?

rewrite ^~/static/(.*)/(.*)$ ~/static/$2 last;

location ^~/static {
        expires max;
        root /var/www;
}

【问题讨论】:

    标签: url nginx rewrite


    【解决方案1】:

    默认情况下,正则表达式中的*' AND+' 是贪婪的。 您必须使用 `.*?'或者写这样的重写:

    最后重写^~/static/[^/]*/(.*)$ ~/static/$1;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多