Nginx中别名alias的使用 位置location作用指定访问资源的根目录针对 http://192.168.242.201/alias/test/test.html;location /alias/testuri /alias/test/test.html;alias /data/test/alias;实际请求资源为/data/test/alias/test.html alias (uri - location)即将uri中匹配location的部分替换为alias的路径添加文件/data/test/alias/test.html 再访问http://192.168.242.201/alias/test/test.html如果访问 http://192.168.242.201/alias/test/test.html/斜杆结尾可以看到test.html被视为目录了添加文件 /data/test/alias/test.html/index.html再访问 http://192.168.242.201/alias/test/test.html/注意保持 alias 的路径和location 路径结尾一致即都不以 / 结尾或都以 / 结尾。如果 alias 使用相对路径资源寻找过程与上述基本一致区别在于资源根目录为 Nginx安装路径 alias 路径访问http://192.168.242.201/alias/test/test.html/资源路径/etc/nginx/alias/test.html/index.html