WordPress Rest API 是一种使用 URL 以 json 格式获取网站数据的方法,可以使用 GET 请求轻松获取网站数据,使得外部网站和客户可以通过接口访问网站的内容,对于开发者来这一功能意义重大,但对于许多用户来说并没有什么用,荒岛本次带来 WordPress 彻底屏蔽 REST API 提升网站安全的教程,只要将下面的代码添加到主题的「functions.php」文件即可。
// 荒岛一座藏有宝藏的小岛 add_filter( 'rest_api_init', 'rest_only_for_authorized_users', 99 ); function rest_only_for_authorized_users($wp_rest_server){ if ( !is_user_logged_in() ) { wp_die('荒岛藏有宝藏的一座小岛'); } }宝藏内容来自荒岛-https://x-imagine.com/wordpress-disable-rest-apis.html宝藏内容来自荒岛-https://x-imagine.com/wordpress-disable-rest-apis.html
请按 Ctrl+D 收藏荒岛分享给好友 如您发现本文件已经失效无法下载请联系站长修正
荒岛公众号
扫一扫关注

HDsoft27
公众号ID已复制,前往微信关注...
荒岛小程序
扫一扫关注

ximagine
哔哩姬ID已复制,前往B站关注...