<div dir="ltr">Hi all.<div><br></div><div>The mission is to conditionally serve *.webp. </div><div><br></div><div>First of all i have map in my http section.</div>
<p class=""><span class="">map $http_accept $webp_suffix {</span></p>
<p class=""><span class=""> default "";</span></p>
<p class=""><span class=""> "~*webp" ".webp";</span></p>
<div> } </div><div><br></div><div>The purpose of this map is to check if the user agent supports the webp.<br></div><div><br></div><div>The second thing we need somehow combine it in try_file.....</div><div>There is an example from config.</div><div>
<p class=""><span class="">location ~ /resize/([-_0-9a-z]+)/([0-9a-z]+)/([0-9a-z]+)/([-_0-9a-z]+)\.jpg$ {</span></p>
<p class=""><span class=""> add_header Vary Accept;</span></p><p class=""><span class="">And there i want to do something like:</span></p><p class=""><span class="">try_files /</span>resize/$1/$2/$3/$4$webp_suffix <span class="">/</span>resize/$1/$2/$3/$4.jpg =404</p><p class="">But it is not working.</p><p class="">The only thing is working is <span class="">try_files $uri</span>$webp_suffix $uri =404. But this combination is checking for image_name.jpg.webp. but i need to look for </p><p class="">image_name.webp.<br></p><p class="">The question is how to concat 2 variables (one from regexp, the other one from map definition) in try section.</p><p class="">Thanks.</p>
<p class=""><span class=""><br></span></p></div></div>