# If( variable exists )

**URL:** <https://www.ruby-forum.com/t/if-variable-exists/218529>\
**Category:** NGINX\
**Created:** [April 3, 2012, 2:35pm UTC](https://www.ruby-forum.com/t/if-variable-exists/218529 "2012-04-03T14:35:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 3, 2012, 2:35pm UTC](https://www.ruby-forum.com/t/if-variable-exists/218529/1 "2012-04-03T14:35:27Z")

</div>

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](http://example.com/?variable)

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

Thanks a lot  
Marcus

Posted at Nginx Forum:

> **[if( variable exists )](https://forum.nginx.org/read.php?2,224860,224860#msg-224860)**
>
> 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 3, 2012, 6:56pm UTC](https://www.ruby-forum.com/t/if-variable-exists/218529/2 "2012-04-03T18:56:52Z")

</div>

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:  
> [Example Domain](http://example.com/?variable)

if ($args ~ variable) {  
…  
}

wbr, Valentin V. Bartenev
