我无法访问tw
文件夹
例如:about.html
我会收到此错误404 Not Found
但我可以访问index.html
页面
server{
server_name great.com;
root /www/gp;
expires off;
try_files $uri/index.html /dev/null =404;
location ~* \.(js|jpg|png|css)$ {
root /www/gp;
expires 30d;
}
location /tw/ {
autoindex on;
root /www/gp/tw;
}
}
.
├── index.html
└── tw
├── about.html
├── brand01.html
├── brand.html
├── contact.html
├── css
├── faq01.html
├── faq02.html
├── images
├── js
└── news.html
2014/10/31 12:00:15 [error] 12047#0: *6 open() "/www/gp/tw/tw/images/waves.gif" failed (2: No such file or directory), client: 118.163.149.126, server: great-compassion.com, request: "GET /
tw/images/waves.gif HTTP/1.1", host: "www.great-compassion.com", referrer: "http://www.great-compassion.com/tw/css/banner.css"
2014/10/31 12:00:18 [error] 12047#0: *5 open() "/www/gp/tw/tw/brand.html" failed (2: No such file or directory), client: 118.163.149.126, server: great-compassion.com, request: "GET /tw/bra
nd.html HTTP/1.1", host: "www.great-compassion.com", referrer: "http://www.great-compassion.com/"
答案 0 :(得分:1)
请勿在两个位置重新定义root
。正如您在错误日志中看到的那样,/www/gp/tw/tw/brand.html
出现两次。也就是说,位置中的路径是包容性的,就像the documentation states about root
一样。
location /i/ {
root /data/w3;
}
将发送/data/w3/i/top.gif
文件以响应/i/top.gif
请求。