# Root not recognized

**URL:** <https://www.ruby-forum.com/t/root-not-recognized/156687>\
**Category:** NGINX\
**Created:** [January 1, 2009, 12:07am UTC](https://www.ruby-forum.com/t/root-not-recognized/156687 "2009-01-01T00:07:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![allins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/97f17d/32.png) [@allins](https://www.ruby-forum.com/u/allins)\
**Post date:** [January 1, 2009, 12:07am UTC](https://www.ruby-forum.com/t/root-not-recognized/156687/1 "2009-01-01T00:07:07Z")

</div>

ok, well better put on root is recognized, a second isnt.

have this setup ( lots of snipping here… )

root /some/path;  
…

location /  
{  
if ( -f /tmp/.maintenance )  
{  
set $site\_maintenance 1;  
}

if ( $site\_maintenance )  
{  
root /maintenance/path;  
rewrite (.\*) /maintenance/index.html;  
}  
}

problem is… the rewrite works just fine but its trying to serve

/some/path/maintenance/index.html  
instead of  
/maintenance/path/maintenance/index.html

any idea why?

---

<div class="post-metadata">

**Author:** ![allins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/97f17d/32.png) [@allins](https://www.ruby-forum.com/u/allins)\
**Post date:** [January 1, 2009, 3:13am UTC](https://www.ruby-forum.com/t/root-not-recognized/156687/2 "2009-01-01T03:13:35Z")

</div>

Try using the $document\_root variable

rewrite (.\*) $document\_root/maintenance/index.html;

On Wed, Dec 31, 2008 at 10:56 PM, Sean A.

---

<div class="post-metadata">

**Author:** ![allins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/97f17d/32.png) [@allins](https://www.ruby-forum.com/u/allins)\
**Post date:** [January 1, 2009, 4:01pm UTC](https://www.ruby-forum.com/t/root-not-recognized/156687/3 "2009-01-01T16:01:25Z")

</div>

That doesn’t work.

I get a 404 for that.

---

<div class="post-metadata">

**Author:** ![allins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/97f17d/32.png) [@allins](https://www.ruby-forum.com/u/allins)\
**Post date:** [January 1, 2009, 4:04pm UTC](https://www.ruby-forum.com/t/root-not-recognized/156687/4 "2009-01-01T16:04:56Z")

</div>

I figured out why the below didnt work for me.

I left out one key point about root /some/path;

We are actually doing:

set $root $base/public;  
root $root;

because conf files are shared by multiple sites. this way each site  
set $base  
and it gets reused in different places… to make the below work, with  
that  
i need to change

> if ( $site\_maintenance )  
> {  
> root /maintenance/path;  
> rewrite (.\*) /maintenance/index.html;  
> }

to

if ( $site\_maintenance )  
{  
set $root /maintenance/path;  
rewrite (.\*) /maintenance/index.html  
}

which is TOTALLY not how I expected variables to work.  
is this documented somewhere?

that if you set root with a variable, to later change root you have  
to change the value of the variable and that using root will have no  
effect?
