Nginx配置。文件从磁盘与检查

Nginx配置。文件从磁盘与检查,nginx,nginx-location,nginx-config,Nginx,Nginx Location,Nginx Config,我不明白如何写逻辑:若文件夹中的文件存在,那个么返回 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; } 您可以将

我不明白如何写逻辑:若文件夹中的文件存在,那个么返回

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;
}

您可以将
root
设置为公共父目录(即
e://
),并使用
try\u files
检查两个目录中的文件

例如:

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

有关详细信息,请参阅。

哦,它的工作!有很多不同的信息。。。我不知道try_文件是否与regex一起工作。谢谢!