# Virtual Document Root

**URL:** <https://www.ruby-forum.com/t/virtual-document-root/202124>\
**Category:** NGINX\
**Created:** [January 22, 2011, 8:32am UTC](https://www.ruby-forum.com/t/virtual-document-root/202124 "2011-01-22T08:32:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 22, 2011, 8:32am UTC](https://www.ruby-forum.com/t/virtual-document-root/202124/1 "2011-01-22T08:32:44Z")

</div>

Hello All,

Is there a configuration for Nginx that is comparable to Apache’s  
VirtualDocumentRoot? For example, in an Apache vhost conf file I can  
have “VirtualDocumentRoot /var/www/html/\_%-2.0.%-1.0/%-3/%-4+/current/”  
and it will map incoming traffic to a specific directory based on the  
URL.

Thanks,  
Blake

---

<div class="post-metadata">

**Author:** ![Blake\_Scrivner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3be4f8/32.png) [@Blake\_Scrivner](https://www.ruby-forum.com/u/Blake_Scrivner)\
**Post date:** [January 22, 2011, 8:52am UTC](https://www.ruby-forum.com/t/virtual-document-root/202124/2 "2011-01-22T08:52:45Z")

</div>

On Fri, Jan 21, 2011 at 03:51:10PM -0800, Blake Scrivner wrote:

> Hello All,
> 
> Is there a configuration for Nginx that is comparable to Apache’s  
> VirtualDocumentRoot? For example, in an Apache vhost conf file I can have  
> “VirtualDocumentRoot /var/www/html/\_%-2.0.%-1.0/%-3/%-4+/current/” and it will map  
> incoming traffic to a specific directory based on the URL.

nginx supports regular expression captures for server name:

> **[Server names](http://nginx.org/en/docs/http/server_names.html#regex_names)**
>
> Server names are defined using the server\_name directive and determine which server block is used for a given request. See also “How nginx processes a request”. They may be defined using exact names, wildcard names, or regular expressions:

–  
Igor S.

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