1. root

1.1. Directives

  1. Syntax: root path ;
  2. Default: root html ;
  3. Context: http,server,location,if in location

1.2. Instroduction

Specify root directory,the request file will like as $documentroot/$uri. For example:
Directive setting: **_root /opt/website ;
request uri: /images/test.jpg** ; nginx will response: /opt/website/images/test.jpg.

2. alias

2.1. Directives

  1. Syntax: alias path ;
  2. Defautl: Close
  3. Context: location

2.2. Instroduction

Defines a replacement for the specified location.For example:

  1. location /i/ {
  2. alias /opt/website/;
  3. }

on request of “/i/top.gif”,the file “/opt/website/top.gif” will be sent.

If alias is used inside a location defined with a regular expression then such regular expression should contain captures and alias should refer to these captures (0.7.40), for example:

  1. location ~ ^/users/(.+\.(?:gif|jpe?g|png))$ {
  2. alias /data/w3/images/$1;
  3. }