# OR conditional usage behavior changed in 0.8.x?

**URL:** <https://www.ruby-forum.com/t/or-conditional-usage-behavior-changed-in-0-8-x/200155>\
**Category:** NGINX\
**Created:** [December 6, 2010, 9:46am UTC](https://www.ruby-forum.com/t/or-conditional-usage-behavior-changed-in-0-8-x/200155 "2010-12-06T09:46:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 6, 2010, 9:46am UTC](https://www.ruby-forum.com/t/or-conditional-usage-behavior-changed-in-0-8-x/200155/1 "2010-12-06T09:46:04Z")

</div>

Hi all,

I used to be able to use the OR conditional this way:  
location = /(40x|50x).html {  
allow all;  
}

It looks like I cannot use it anymore in 0.8.53 version. Can you please  
let me know what is the new type of compact condition I should use  
instead?  
Thanks for your help.

Posted at Nginx Forum:

> **[OR conditional usage behavior changed in 0.8.x?](https://forum.nginx.org/read.php?2,155932,155932#msg-155932)**
>
> Hi all, I used to be able to use the OR conditional this way: location = /(40x|50x).html { allow all; } It looks like I cannot use it anymore in 0.8.53 version. Can you please let me know what is the new type of compact condition I should use ins

---

<div class="post-metadata">

**Author:** ![teck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b2d939/32.png) [@teck](https://www.ruby-forum.com/u/teck)\
**Post date:** [December 6, 2010, 1:08pm UTC](https://www.ruby-forum.com/t/or-conditional-usage-behavior-changed-in-0-8-x/200155/2 "2010-12-06T13:08:46Z")

</div>

On Mon, Dec 06, 2010 at 03:45:02AM -0500, TECK wrote:

> Hi all,
> 
> I used to be able to use the OR conditional this way:  
> location = /(40x|50x).html {  
> allow all;  
> }
> 
> It looks like I cannot use it anymore in 0.8.53 version. Can you please  
> let me know what is the new type of compact condition I should use  
> instead?

It never worked. This works:

location ~ ^/(40x|50x).html {

However, I do not recommend to use regexs if they can be avoided:  
they complicate configuration maintence.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![teck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b2d939/32.png) [@teck](https://www.ruby-forum.com/u/teck)\
**Post date:** [December 6, 2010, 1:18pm UTC](https://www.ruby-forum.com/t/or-conditional-usage-behavior-changed-in-0-8-x/200155/3 "2010-12-06T13:18:09Z")

</div>

Hello!

On Mon, Dec 06, 2010 at 03:45:02AM -0500, TECK wrote:

> Hi all,
> 
> I used to be able to use the OR conditional this way:  
> location = /(40x|50x).html {  
> allow all;  
> }

This location should match only requests to “/(40x|50x).html” in  
all versions.

> It looks like I cannot use it anymore in 0.8.53 version. Can you please  
> let me know what is the new type of compact condition I should use  
> instead?  
> Thanks for your help.

If you want regexp to work you have to mark location as regexp-one  
with “~” modifier (and rewrite regexp to be correct), i.e.

```
location ~ ^/(40x|50x)\.html$ {
    allow all;
}

```

Though I really recommend using two normal (or exact match) locations  
instead, i.e.

```
location = /40x.html {
    allow all;
}
location = /50x.html {
    allow all;
}

```

Maxim D.

---

<div class="post-metadata">

**Author:** ![teck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b2d939/32.png) [@teck](https://www.ruby-forum.com/u/teck)\
**Post date:** [December 7, 2010, 11:41pm UTC](https://www.ruby-forum.com/t/or-conditional-usage-behavior-changed-in-0-8-x/200155/4 "2010-12-07T23:41:57Z")

</div>

Thanks a lot Maxim and Igor for the replies.  
Is there a more compact way to write several directories, into one  
line?

Right now I have many directories not allowed:

`location /dir/(alpha|gamma/beta|theta|epsilon/delta/tmp|omega)/ {
  allow 127.0.0.1;
  deny all;
}`

This is just an example, I have about 20 dirs that needs to be  
protected.  
Do I have to write each one of them individually in order to preserve  
efficiency?  
I could create an additional .conf file and include it into  
configuration, for sanity reasons.  
I just need to know if is best to have the locations separate.

Thanks.

Posted at Nginx Forum:

> **[Re: OR conditional usage behavior changed in 0.8.x?](https://forum.nginx.org/read.php?2,155932,156574#msg-156574)**
>
> Hi all, I used to be able to use the OR conditional this way: location = /(40x|50x).html { allow all; } It looks like I cannot use it anymore in 0.8.53 version. Can you please let me know what is the new type of compact condition I should use ins
