nginx specify a file path in two ways root and alias

 

background

      Never understand this configuration What do you mean, anyway, make do with it, but the old makeshift total is not a thing, not understood more easily forgotten, others also asked not answer. Anyway, it is also very simple, you do understand the point down.

Knowledge Point

root Example: 

^ ~ LOCATION / T / { 
     the root / WWW / the root / HTML /; 
} 

When the request is a URI if /t/a.html, web server will return / www / root / html / t / a on the server. the html file. 

alias example: 

location ^~ /t/ {
 alias /www/root/html/new_t/;
}

If a requested URI is /t/a.html time, web server will return /www/root/html/new_t/a.html of files on the server. Note that this is new_t, because the path behind the location of the alias will discard configuration, to match the current directory to the specified directory points. 

note:

1. When using the alias, the directory name must be added "/."
3. alias when using a regular match, must capture content to be matched and used at the specified content.
4. alias location located block only. (Root can not be placed in the location)

      Never understand this configuration What do you mean, anyway, make do with it, but the old makeshift total is not a thing, not understood more easily forgotten, others also asked not answer. Anyway, it is also very simple, you do understand the point down.

Knowledge Point

root Example: 

^ ~ LOCATION / T / { 
     the root / WWW / the root / HTML /; 
} 

When the request is a URI if /t/a.html, web server will return / www / root / html / t / a on the server. the html file. 

alias example: 

location ^~ /t/ {
 alias /www/root/html/new_t/;
}

If a requested URI is /t/a.html time, web server will return /www/root/html/new_t/a.html of files on the server. Note that this is new_t, because the path behind the location of the alias will discard configuration, to match the current directory to the specified directory points. 

note:

1. When using the alias, the directory name must be added "/."
3. alias when using a regular match, must capture content to be matched and used at the specified content.
4. alias location located block only. (Root can not be placed in the location)

Guess you like

Origin www.cnblogs.com/jasonxiaoqinde/p/11828787.html