multiple roots for multiple sites

Maxim Dounin mdounin at mdounin.ru
Sat May 15 03:28:31 MSD 2010


Hello!

On Fri, May 14, 2010 at 03:31:00PM -0700, John Magolske wrote:

> I'm working on multiple sites & would like to specify different
> roots for each one so that identical absolute urls such as
> <a href="/index.html">Home</a> on each site don't all get
> directed to the same /usr/local/nginx/html/index.html
> 
> ie,
> 
> navigate to http://localhost/site1 & the root will be
> /usr/local/nginx/html/site1
> 
> navigate to http://localhost/site2 & the root will be
> /usr/local/nginx/html/site2
>
> I tried this:
> 
>     location /site1/ {
>         root   /usr/local/nginx/html/site1;

-         root   /usr/local/nginx/html/site1;
+         alias  /usr/local/nginx/html/site1/;

Directive "root" defines path to a server root (i.e. to "/" 
uri), and filename calculated as <root> + <uri>.

Directive "alias" specifies path to a matched location, and 
filename calculated as <alias> + <part of uri not matched by 
location>.

See here for details:

http://wiki.nginx.org/NginxHttpCoreModule#root
http://wiki.nginx.org/NginxHttpCoreModule#alias

Maxim Dounin



More information about the nginx mailing list