码迷,mamicode.com
首页 > 其他好文 > 详细

nginx alias

时间:2014-12-15 23:16:01      阅读:389      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   sp   for   strong   on   art   bs   

A path to the file is constructed by merely adding a URI to the value of the root directive. If a URI has to be modified, the alias directive should be used

 

Syntax: alias path;
Default:
Context: location

Defines a replacement for the specified location. For example, with the following configuration

location /i/ {
    alias /data/w3/images/;
}

on request of “/i/top.gif”, the file /data/w3/images/top.gif will be sent.

The path value can contain variables, except $document_root and $realpath_root.

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:

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

 

When location matches the last part of the directive’s value:

location /images/ {
    alias /data/w3/images/;
}

it is better to use the root directive instead:

location /images/ {
    root /data/w3;
}

 

nginx alias

标签:http   io   ar   sp   for   strong   on   art   bs   

原文地址:http://www.cnblogs.com/argb/p/4165925.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!