Nginx - location块中的alias和try_files重定向

nginx.conf片段:

location /logo/general/ {

    autoindex_localtime on;

    alias /opt/config/;

    try_files /logo/logo.png /www/html/logo.png =404;

}

意为:访问/logo/general/地址时,

如:访问http://127.0.0.1/logo/general/logo.png的时候,

在location块中,使用了alias将目录重定向到了/opt/congig,

然后try_files关键字尝试查找/opt/config/logo/logo.png并返回,如果不存在则返回/opt/config/www/html/logo.png,都不存在,则返回404

猜你喜欢

转载自blog.csdn.net/xuezhangjun0121/article/details/135411062