修复方法分为Apache 和Nginx服务:

Apache :

1、修改主题目录下function.php文件 wp-content/themes/主题目录/functions.php  ,添加以下代码:

add_filter( ‘rest_endpoints’, function( $endpoints ){
if ( isset( $endpoints[‘/wp/v2/users’] ) ) {
unset( $endpoints[‘/wp/v2/users’] );
}
return $endpoints;
});

2、在网站根目录下.htaccess 文件添加屏蔽规则

RewriteEngine On
RewriteRule ^wp-json/wp/v2/users(/.*)?$ - [F,L]
以上就修复完成了,可以直接验证 ,再访问就是 403 了。




Nginx修复:

在网站nginx配置文件 server模块中 添加如下代码。

   
    location ~ ^/wp-json/wp/v2/users(/.*)?$ {
        deny all;
        return 403;  # 访问会返回 403 Forbidden
    }

保存配置文件,reload下nginx