Too many define location directive

steve steve at greengecko.co.nz
Mon Apr 24 02:07:17 UTC 2017


Hi,

On 23/04/17 05:36, Dewangga Bachrul Alam wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Hello!
>
> I got confused and no hint(s) about map directive co-exist with
> try_files directive. Is it right to think using map directive? Or any
> alternative?
>
> The goals is, I want to avoid many location like :
>
> ... snip ...
>          index   index.php;
>          try_files $uri $uri/ /index.php?q=$uri&$args;
>          root    /var/www/api.domain.tld;
>
>          location /v2 {
>                  try_files $uri $uri/ /v2/index.php?q=$uri&$args;
>          }
>
>          location /v3 {
>                  try_files $uri $uri/ /v3/index.php?q=$uri&$args;
>          }
>
> location ~ \.php$ {
>          fastcgi_param  SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
>          ... rest fastcgi stuff there ...
> }
> ...
>
> That config above are works fine, but too many location "/v[0-9]+" in
> config file. So, if there are v4, v5, etc are exists in
> /var/www/api.domain.tld, the configuration won't change.
>
> Any helps are appreciate.
> Thanks.
>

use a map??

-- 
Steve Holdoway BSc(Hons) MIITP
https://www.greengecko.co.nz/
Linkedin: https://www.linkedin.com/in/steveholdoway
Skype: sholdowa



More information about the nginx mailing list