thinkphp5固定原有自带规则
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
现在想实现 IP白名单
但接口是 开放给全部人的 按道理应该很简单
location /api
{
allow all;
}
但是/api 非实际文件或目录 ,会跳转到/index.php?s=api
按照上面的规则配置的日志
2019/05/10 13:11:50 [error] 23747#0: *11173 open() "/home/wwwroot/.com/public/api" failed (2: No such file or directory), client: 149.129.0.205, server: .com, request: "GET /api HTTP/2.0", host: ".com"
按照下面的规则配置的日志
location /api
{
allow all;
rewrite ^(.*)$ /index.php?s=/$1 last;
}
2019/05/10 13:13:04 [notice] 23765#0: *11175 "^(.*)$" matches "/api", client: 149.129.0.205, server: ..com, request: "GET /api HTTP/2.0", host: "..com"
2019/05/10 13:13:04 [notice] 23765#0: *11175 rewritten data: "/index.php", args: "s=//api", client: 149.129.0.205, server: ..com, request: "GET /api HTTP/2.0", host: "..com"
2019/05/10 13:13:04 [error] 23765#0: *11175 acce forbidden by rule, client: 149.129.0.205, server: ..com, request: "GET /api HTTP/2.0", host: "..com"
求大佬赐一条规则 ,请大佬喝个可乐