测试
if ($request_uri !~* "/testdir/?") {
rewrite ^(.*) /testdir$1 last;
}
开启重写日志进一步分析,但没看懂。
"/testdir/?" does not match "/", client: 1.1.1.1, server: xxx.com, request: "GET / HTTP/2.0", host: "xxx.com"
"^(.*)" matches "/", client: 1.1.1.1, server: xxx.com, request: "GET / HTTP/2.0", host: "xxx.com"
rewritten data: "/testdir/", args: "", client: 1.1.1.1, server: xxx.com, request: "GET / HTTP/2.0", host: "xxx.com"
"/testdir/?" does not match "/", client: 1.1.1.1, server: xxx.com, request: "GET / HTTP/2.0", host: "xxx.com"
"^(.*)" matches "/testdir/index.php", client: 1.1.1.1, server: xxx.com, request: "GET / HTTP/2.0", host: "xxx.com"
rewritten data: "/testdir/testdir/index.php", args: "", client: 1.1.1.1, server: xxx.com, request: "GET / HTTP/2.0", host: "xxx.com"
换成以下规则测试 OK
if ($document_uri !~* "/testdir/?") {
rewrite ^(.*) /testdir$1 last;
}
1
kiddult 2019 年 4 月 4 日
|
2
ropon OP |
4
msg7086 2019 年 4 月 5 日
新开一个 location 可能会更简单明了一些。
|