if( variable exists )

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

if( variable exists )

vedranf
Hello,

Is there a chance to test if a "$arg_variable" (empty value) exists?
The problem: "if" condition returns "false".

URL:
http://example.com/?variable

nginx.conf:
location / {
if( $arg_variable ) {
rewrite ^.*$ /other-location;
}
}

Thanks a lot
Marcus

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,224860,224860#msg-224860

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: if( variable exists )

Valentin V. Bartenev-2
On Tuesday 03 April 2012 16:35:02 double wrote:
> Hello,
>
> Is there a chance to test if a "$arg_variable" (empty value) exists?
> The problem: "if" condition returns "false".
>
> URL:
> http://example.com/?variable
>

  if ($args ~ variable) {
     ...
  }

 wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: if( variable exists )

wld75
if ($arg_user)
{
           do as  $arg_user exist
bla bla bbla
}

if ($arg_user !~ $arg_user)
{
  do as $arg_user not exist
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,224860,279847#msg-279847

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: if( variable exists )

wld75
In reply to this post by Valentin V. Bartenev-2
$arg_proxy
?aaa.com?proxy

```
 if ($args ~ '(&|^)proxy([&=]|$)' ) { #exists
   set $port '8080';
 }
```

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,224860,281102#msg-281102

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx