测试
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-04-04 18:54:20 +08:00
|
2
ropon OP |
3
kiddult 2019-04-04 20:30:06 +08:00
@ropon 就是对于 xxx. com 这个请求,`$document_uri` 和 `$request_uri` 产生的效果应该是一致的
|
4
msg7086 2019-04-05 20:55:40 +08:00
新开一个 location 可能会更简单明了一些。
|