Set location based on query arg
Francis Daly
francis at daoine.org
Fri Nov 11 08:30:06 UTC 2016
On Thu, Nov 10, 2016 at 06:46:10PM -0500, ulik wrote:
Hi there,
> Here is what I want to do, in nginx conf language:
> # root when path query arg is present
> if ($arg_path) {
> root /var/www/example/$arg_path;
> }
>
> # root when path query arg is not present (default)
> if (!$arg_path) {
> root /var/www/example/default;
> }
You can use "map" to set a variable, and then use that variable in the
"root" directive. That way you can avoid trying to have "root" within
"if".
Something like
map $arg_path $root_bit {
default $arg_path;
"" default;
}
and then later
root /var/www/example/$root_bit;
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list