Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Url 为静态目录重写NGINX_Url_Nginx_Rewrite - Fatal编程技术网

Url 为静态目录重写NGINX

Url 为静态目录重写NGINX,url,nginx,rewrite,Url,Nginx,Rewrite,我想翻译: mydomain.com/98387634/image/file.png 致: mydomain.com/image/file.png 有人能告诉我我的重写有什么问题吗 rewrite ^~/static/(.*)/(.*)$ ~/static/$2 last; location ^~/static { expires max; root /var/www; } 默认情况下,正则表达式中的*”和+”是贪婪的。 您必须使用`.''或写或重写如下内容:

我想翻译:

mydomain.com/98387634/image/file.png

致:

mydomain.com/image/file.png

有人能告诉我我的重写有什么问题吗

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

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

默认情况下,正则表达式中的*”和+”是贪婪的。 您必须使用`.''或写或重写如下内容:

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