Nginx配置。磁盘上带有检查的文件

问题描述 投票:1回答:1

我不明白如何写逻辑:如果文件夹中的文件存在,则返回;

location ~ "/((\w{2})[\w-]+\.(png|jpg))$" {

    if(-f e:\\ThumbFull\\$2\\$1){
        alias  e:\\ThumbFull\\$2\\$1;   
    }

    if(-f e:\\Image\\$2\\$1){
        alias  e:\\Image\\$2\\$1;   
    }
    return 404;
}
nginx nginx-location nginx-config
1个回答
0
投票

您可以将root设置为公共父目录(即e:/),然后使用try_files检查两个目录中的文件。

例如:

location ~ "/((\w{2})[\w-]+\.(png|jpg))$" {
    root e:/;
    try_files /ThumbFull/$2/$1 /Image/$2/$1 =404;
}

有关详细信息,请参见this document

© www.soinside.com 2019 - 2024. All rights reserved.