Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

Is it possible to use 2 variables (one from regexp, the other one from map definition)? (1 reply)

$
0
0
Hi all.

The mission is to conditionally serve *.webp.

First of all i have map in my http section.

map $http_accept $webp_suffix {

default "";

"~*webp" ".webp";
}

The purpose of this map is to check if the user agent supports the webp.

The second thing we need somehow combine it in try_file.....
There is an example from config.

location ~
/resize/([-_0-9a-z]+)/([0-9a-z]+)/([0-9a-z]+)/([-_0-9a-z]+)\.jpg$ {

add_header Vary Accept;

And there i want to do something like:

try_files /resize/$1/$2/$3/$4$webp_suffix /resize/$1/$2/$3/$4.jpg =404

But it is not working.

The only thing is working is try_files $uri$webp_suffix $uri =404. But this
combination is checking for image_name.jpg.webp. but i need to look for

image_name.webp.

The question is how to concat 2 variables (one from regexp, the other one
from map definition) in try section.

Thanks.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>