padavan
padavan

Reputation: 875

Nginx config. File from disk with check

I dont understand how i can write logic : if file in folder exists then return;

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

Upvotes: 0

Views: 282

Answers (1)

Richard Smith
Richard Smith

Reputation: 49682

You could set root to a common parent directory (i.e. e:/) and use try_files to check for the file in both directories.

For example:

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

See this document for details.

Upvotes: 1

Related Questions