当前位置: 动力学知识库 > 问答 > 编程问答 >

Regex language code in nginx location path

问题描述:

Hi I have these two block (working well)

location ^~ /beta/vi/static/ {

include /etc/nginx/mime.types;

alias /path/static/ ;

}

location ^~ /beta/en/static/ {

include /etc/nginx/mime.types;

alias /path/static/ ;

}

Can I merge them into 1 block, for catching vi and en ?

网友答案:

You need a regex location (~*) for that:

location ~* ^/beta/(vi|en)/static/(.*)$ {
    include  /etc/nginx/mime.types;
    alias /path/static/$2;
}

You can add more to the list if necessary, like (vi|en|bla).

分享给朋友:
您可能感兴趣的文章:
随机阅读: