Questions about root and alias directives

Nikolaos Milas nmilas at noa.gr
Fri Jan 20 10:15:30 UTC 2017


Hello,

I need a config which includes multiple different physical paths.

So I have:

    server {

         listen [::]:80;
         ...
         root   /var/webs/wwwmain/www/;

         index index.php index.html index.htm;

         ...

         location / {
             try_files $uri $uri/ /index.php?$args;
         }

         location /museum/ {
             root /var/webs/wwwmuseum/;
         }

         ...

    }

Now, when I request "http://www.example.com/museum/", the above config 
produces a request for the following path:

    /var/webs/wwwmuseum/museum/index.php

I think this is the expected result, according to the documentation.

If I change the last part to use an alias directive:

         location /museum/ {
             alias /var/webs/wwwmuseum/;
         }

then the evaluated path becomes:

    /var/webs/wwwmain/www/museum/index.html

The alias directive does not seem to have any effect. (Why is that so?)

So, in both cases, I cannot achieve the *desired* path which is:

    /var/webs/wwwmuseum/index.html

How should I do it?

Thanks in advance,
Nick



More information about the nginx mailing list