# What is the difference between alias and root

**URL:** <https://www.ruby-forum.com/t/what-is-the-difference-between-alias-and-root/194844>\
**Category:** NGINX\
**Created:** [September 12, 2010, 6:36am UTC](https://www.ruby-forum.com/t/what-is-the-difference-between-alias-and-root/194844 "2010-09-12T06:36:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Matthews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@James\_Matthews](https://www.ruby-forum.com/u/James_Matthews)\
**Post date:** [September 12, 2010, 6:36am UTC](https://www.ruby-forum.com/t/what-is-the-difference-between-alias-and-root/194844/1 "2010-09-12T06:36:15Z")

</div>

I was wondering what the difference was between alias and root in the  
server  
block on nginx was?

They seem to provide the same functionality.

James

---

<div class="post-metadata">

**Author:** ![James\_Matthews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@James\_Matthews](https://www.ruby-forum.com/u/James_Matthews)\
**Post date:** [September 12, 2010, 11:18am UTC](https://www.ruby-forum.com/t/what-is-the-difference-between-alias-and-root/194844/2 "2010-09-12T11:18:19Z")

</div>

On Sat, Sep 11, 2010 at 09:35:10PM -0700, James Matthews wrote:

> I was wondering what the difference was between alias and root in the server  
> block on nginx was?
> 
> They seem to provide the same functionality.

The alias is supported on a location level only for the obvious reason.

–  
Igor S.

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

---

<div class="post-metadata">

**Author:** ![James\_Matthews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@James\_Matthews](https://www.ruby-forum.com/u/James_Matthews)\
**Post date:** [September 13, 2010, 8:46pm UTC](https://www.ruby-forum.com/t/what-is-the-difference-between-alias-and-root/194844/3 "2010-09-13T20:46:12Z")

</div>

## James Matthews Wrote:

> I was wondering what the difference was between  
> alias and root in the server  
> block on nginx was?

There’s a subtle difference.

```auto
# This will result in files being searched for in /foo/bar/bar as the
full URI is appended.
location /bar {
    root /foo/bar;
}

# This will result in files being searched for in /foo/bar as only the
URI part after /bar is appended.
location /bar {
    alias /foo/bar;
}
```

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,129656,130107#msg-130107](http://forum.nginx.org/read.php?2,129656,130107#msg-130107)
