WP REST API与LiteSpeed兼容性问题求助:REST API报错、插件编辑器无法保存及插件无法更新
各位大佬好,我已经折腾好几天了,每天花差不多10小时排查这个问题,能想到的办法都试了,网上也搜遍了,实在没辙了来求助!
遇到的问题:
- 在WordPress站点健康检测中,出现REST API相关报错:
The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.
测试REST API时返回了意外结果:
REST API Endpoint: https://www.mydomain.gr/wp-json/wp/v2/types/post?context=edit
REST API Response: (400) Bad Request
- 尝试从插件编辑器保存文件时(已经确认文件权限没问题,甚至试过设置777权限),出现:
Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.
- 插件无法和服务器通信检查更新。
日志信息:
每次尝试从文件编辑器写.php文件,或者运行站点健康检测时,LiteSpeed的error_log里都会出现这条记录:
2024-03-15 09:45:58.850109 [INFO] [2276963] [T0] [23.88.68.54:35334] Status 400: Invalid character in header name: '],"is_nat"'
已尝试的解决方案:
- 调整过LiteSpeed的各项设置
- 禁用所有插件并切换到默认主题
- 替换为WordPress默认的.htaccess文件
- 写了个小PHP脚本测试和wc-api通信,完全正常(这就更奇怪了...)
- 重新安装了WordPress 6.4.3版本
实在搞不懂问题出在哪了,求各位大佬指点!
备注:内容来源于stack exchange,提问作者Menelaos pc

