Welcome! Log In Create A New Profile

Advanced

Re: Set location based on query arg

Francis Daly
November 11, 2016 03:32AM
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@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Set location based on query arg

ulik November 10, 2016 03:04PM

Re: Set location based on query arg

Francis Daly November 10, 2016 05:22PM

Re: Set location based on query arg

ulik November 10, 2016 06:46PM

Re: Set location based on query arg

Francis Daly November 11, 2016 03:32AM

Re: Set location based on query arg

Francis Daly November 11, 2016 03:42AM

Re: Set location based on query arg

ulik November 11, 2016 12:34PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 279
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready