Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have found answers to my confusions.</p> <p>There is a very important difference between the <code>root</code> and the <code>alias</code> directives. This difference exists in the way the path specified in the <code>root</code> or the <code>alias</code> is processed.</p> <p>In case of the <code>root</code> directive, <strong>full path is appended to the root <em>including the location part</em></strong>, whereas in case of the <code>alias</code> directive, <strong>only the portion of the path <em>NOT including the location part</em> is appended to the alias</strong>.</p> <p>To illustrate:</p> <p>Let's say we have the config</p> <pre><code> location /static/ { root /var/www/app/static/; autoindex off; } </code></pre> <p>In this case the final path that Nginx will derive will be</p> <pre><code>/var/www/app/static/static </code></pre> <p>This is going to return <code>404</code> since there is no <code>static/</code> within <code>static/</code></p> <p>This is because the location part is appended to the path specified in the <code>root</code>. Hence, with <code>root</code>, the correct way is</p> <pre><code> location /static/ { root /var/www/app/; autoindex off; } </code></pre> <p>On the other hand, with <code>alias</code>, the location part gets <strong>dropped</strong>. So for the config</p> <pre><code> location /static/ { alias /var/www/app/static/; autoindex off; } </code></pre> <p>the final path will correctly be formed as</p> <pre><code>/var/www/app/static </code></pre> <p>See the documentation here: <a href="http://wiki.nginx.org/HttpCoreModule#alias" rel="noreferrer">http://wiki.nginx.org/HttpCoreModule#alias</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload