【发布时间】:2020-09-08 05:22:22
【问题描述】:
我试图将我的子路径设置为仅在 Nginx 中列出的目录,但是它返回 404。
假设我有 http://file.example.com/test 的以下配置:
server {
listen 80;
server_name file.example.com;
location /test/ {
root /var/www/abc/def/;
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime on;
}
}
我没有指定/ 部分,是不是上面导致的问题不起作用?我错过了什么?
【问题讨论】:
-
文件在哪个目录下?
-
@RichardSmith
http://file.example.com/test应该列出/var/www/abc/def/中的文件 -
Nginx 正在
/var/www/abc/def/test/的目录中查找文件。尝试使用alias而不是root。例如:alias /var/www/abc/def/;
标签: nginx nginx-location nginx-config