测试
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;
}