1,我的配置文件中写的rewrite如下
location /lucy/ {
rewrite ^/lucy/(.*)$ /lucy/access/$1 break;
#rewrite .* /lucy/access/a/b/index.html break;
root /tmp/data/luxin/;
index index.html index.htm;
}
1
2
3
4
5
6
7
网站的网页目录如下
[root@nginx b]# pwd
/tmp/data/luxin/lucy/access/a/b
[root@nginx b]# ls
index.html
1
2
3
4
访问方法
[root@centos07 ~]# curl -v -L 192.168.100.108/lucy/a/b/
1
本人认为我在访问时匹配到/lucy的location项,然后地址重写到/lucy/access/a/b,然后再次访问这个url,但为什么访问404呢?求解答
错误日志如下:
2022/10/28 23:19:27 [error] 35214#0: *276 open() "/tmp/data/luxin/lucy/access/access/a/b/index.html" failed (2: No such file or directory), client: 192.168.100.107, server: 192.168.100.108, request: "GET /lucy/a/b/ HTTP/1.1", host: "192.168.100.108"
2022/10/28 23:19:33 [error] 35214#0: *277 "/tmp/data/luxin/lucy/access/access/a/b/index.html" is not found (2: No such file or directory), client: 192.168.100.107, server: 192.168.100.108, request: "GET /lucy/access/a/b/ HTTP/1.1", host: "192.168.100.108"
1
2
为什么会多一个access目录,break不应该就匹配一次就结束了吗?