仅列出子路径的Nginx目录
我试图使我的子路径仅在Nginx中作为目录列表,但是它返回404 假设我对仅列出子路径的Nginx目录,nginx,nginx-location,nginx-config,Nginx,Nginx Location,Nginx Config,我试图使我的子路径仅在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;
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;
}
}
我没有指定
/
部分,是不是上面的问题导致无法工作?有什么遗漏吗?将位置更改为位置/测试
将所有文件复制到/var/www/abc/def/test
文件夹,因为您使用的是location指令和root指令。在您的情况下,当Nginx搜索静态文件时,它将使用根路径/var/www/abc/def
,并附加位置路径/test
或者使用@RichardSmith建议的别名。将位置更改为
位置/测试
将所有文件复制到/var/www/abc/def/test
文件夹,因为您使用的是location指令和root指令。在您的情况下,当Nginx搜索静态文件时,它将使用根路径/var/www/abc/def
,并附加位置路径/test
或者按照@RichardSmith的建议使用别名。文件在哪个目录下?@RichardSmith
http://file.example.com/test
应列出/var/www/abc/def/
中的文件Nginx正在/var/www/abc/def/test/
目录中查找文件。尝试使用alias
而不是root
。例如:alias/var/www/abc/def/代码>文件在哪个目录下?@RichardSmithhttp://file.example.com/test
应列出/var/www/abc/def/
中的文件Nginx正在/var/www/abc/def/test/
目录中查找文件。尝试使用alias
而不是root
。例如:alias/var/www/abc/def/代码>