Nginx服务定制css文件

Nginx服务定制css文件,nginx,nginx-location,Nginx,Nginx Location,比如说,我有一个location/user/username/custom/custom.css,我想将这个location/user/*/custom/发送到location/var/www/custom,我不知道如何编写NginX规则。 我试过了 但这样的规则是行不通的 有什么建议吗? 谢谢好的,我终于明白了。正确的解决办法至少我希望是这样 location ~* /user/(.*)/custom/(.*) { alias /var/www/custom/$2; } 我的和这个很

比如说,我有一个location/user/username/custom/custom.css,我想将这个location/user/*/custom/发送到location/var/www/custom,我不知道如何编写NginX规则。 我试过了

但这样的规则是行不通的

有什么建议吗?
谢谢

好的,我终于明白了。正确的解决办法至少我希望是这样

location ~* /user/(.*)/custom/(.*) {
   alias /var/www/custom/$2; 
}

我的和这个很相似

location ~* /user/[^/]+/custom/(.*) {
   alias /var/www/custom/$1;
}
你的问题,下面将导致相同的文件

/user/username/abc/test/custom/test.css
/user/username/abc/custom/test.css
/user/username/custom/test.css

我的将在前2页上给出404,在最后一页上给出正确的文件

是的,我理解……这是更好的一页。非常感谢你。
/user/username/abc/test/custom/test.css
/user/username/abc/custom/test.css
/user/username/custom/test.css