2017-08-28 89 views
0

讓我們說,我有一個位置/user/username/custom/custom.css我想將這個位置/user/(.*)/custom/的位置/var/www/custom我不知道,如何編寫NginX規則。 我試過Nginx自定義css文件

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

但是這樣的規則不起作用。

有什麼建議嗎? 謝謝

回答

0

好吧,最後我想通了。正確的解決方案(至少我希望如此)是

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

好我的是類似這樣的

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,最後一個給你正確的文件

+0

是的,我明白...這是更好的一個。非常感謝。 –