# If set variable unfamiliar language

**URL:** <https://www.ruby-forum.com/t/if-set-variable-unfamiliar-language/180460>\
**Category:** NGINX\
**Created:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/if-set-variable-unfamiliar-language/180460 "2009-12-19T15:25:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/if-set-variable-unfamiliar-language/180460/1 "2009-12-19T15:25:42Z")

</div>

I’ve seen code for virtual domains in the nginx.conf to handle setups  
with WP Super Cache using an if condition that appears to assign a  
variable value with “set” as shown in the example below.

Could someone provide me with a link, or links, where I can see some  
examples of how this is used, how to use set, and what language it is  
from, so I can write some of my own configurations using this approach?

# if the requested file exists, return it immediately

```
           if (-f $request_filename) {
                   break;
           }

           set $supercache_file '';
           set $supercache_uri $request_uri;

           if ($request_method = POST) {
                   set $supercache_uri '';
           }

```

# Using pretty permalinks, so bypass the cache for any query string

```
           if ($query_string) {
                   set $supercache_uri '';
           }

           if ($http_cookie ~* 

```

“comment\_author\_|wordpress|wp-postpass\_” ) {  
set $supercache\_uri ‘’;  
}

Posted at Nginx Forum:

> **[if set variable unfamiliar language](https://forum.nginx.org/read.php?2,31203,31203#msg-31203)**
>
> I've seen code for virtual domains in the nginx.conf to handle setups with WP Super Cache using an if condition that appears to assign a variable value with "set" as shown in the example below. Could someone provide me with a link, or...

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/if-set-variable-unfamiliar-language/180460/2 "2009-12-19T15:25:42Z")

</div>

I see [Module ngx\_http\_rewrite\_module](http://wiki.nginx.org/NginxHttpRewriteModule) now, but I am still  
unsure about how some of the logic works. For example the follow rewrite  
code block allows YOURLS to be properly used with Nginx, but I don’t see  
how this flows logically.:

```
    if (!-f $request_filename){
      set $rule_0 1$rule_0;
    }
    if (!-d $request_filename){
      set $rule_0 2$rule_0;
    }
    if ($rule_0 = "21"){
    rewrite ^/([0-9a-z]+)/?$ /yourls-go.php?id=$1 last;
    }

```

Posted at Nginx Forum:

> **[Re: if set variable unfamiliar language](https://forum.nginx.org/read.php?2,31203,31215#msg-31215)**
>
> I've seen code for virtual domains in the nginx.conf to handle setups with WP Super Cache using an if condition that appears to assign a variable value with "set" as shown in the example below. Could someone provide me with a link, or...

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/if-set-variable-unfamiliar-language/180460/3 "2009-12-19T15:25:42Z")

</div>

On Thu, Dec 17, 2009 at 5:48 PM, nerdgrind [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rewrite ^/([0-9a-z]+)/?$ /yourls-go.php?id=$1 last;  
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }

also read try\_files for such task

location ~ ^/([\da-z]+)/?$  
{  
try\_files $uri $uri/ /yourls-go.php?id=$1;  
}

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/if-set-variable-unfamiliar-language/180460/4 "2009-12-19T15:25:42Z")

</div>

References for others:

[http://wiki.nginx.org/NginxHttpCoreModule#try\_files](http://wiki.nginx.org/NginxHttpCoreModule#try_files)

> **[WordPress | NGINX](https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/)**
>
> A sample NGINX configuration for WordPress.

Posted at Nginx Forum:

> **[Re: if set variable unfamiliar language](https://forum.nginx.org/read.php?2,31203,31347#msg-31347)**
>
> I've seen code for virtual domains in the nginx.conf to handle setups with WP Super Cache using an if condition that appears to assign a variable value with "set" as shown in the example below. Could someone provide me with a link, or...

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/if-set-variable-unfamiliar-language/180460/5 "2009-12-19T15:25:42Z")

</div>

On Thu, Dec 17, 2009 at 5:05 PM, nerdgrind [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Â Â Â Â Â Â Â set $supercache\_file ‘’;
> 
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)
