WordPress禁用xmlrpc.php

·

Codioful formerly gradienta iIeBtdQf bg unsplash

xmlrpc.php是已经逐渐被淘汰的一个功能,用途就是让你的WordPress网站与外界联系,因其本身的很多缺陷,逐渐被更好更安全的REST API代替。

潜在风险

一是DDoS,通过XML-RPC Pingbacks DDoS攻击网站。

二是Brute Force攻击,通过不断的登录验证攻击网站。

禁用xmlrpc.php

方法很多,可以安装插件,某些安全插件可以关闭,这里推荐修改 .htacess。

在 .htacess文件中添加如下代码即可。

<Files "xmlrpc.php">
  Require all denied
</Files>

验证

xmlrpc.blog/#

这个网站可以测试xmlrpc.php是否禁用

禁用前:

屏幕截图 5 2 2026 94822 xmlrpc.blog

禁用后:

屏幕截图 5 2 2026 9503 xmlrpc.blog

Jetpack

如果你需要使用Jetpack去管理你的网站,那么直接关闭xml-rpc就会导致很多功能无法使用。参考官方文档:

Jetpack and XML-RPC
XML-RPC is a communication protocol that Jetpack uses to connect your site to WordPress.com. Learn more about XML-RPC and how it powers Jetpack. What is XML-RPC? XML-RPC is a protocol that allows c…
jetpack.com

那么可以考虑通过插件去关闭部分功能,或者使用下面的代码,将Jetpack的IP排除。

<Files xmlrpc.php>
order deny,allow
deny from all
allow from 192.0.64.0/18
</Files>

参考

如何彻底禁用 WordPress 的 XML-RPC 接口(2025 最新实践) – 内网笔记
在 WordPress 的历史中,XML-RPC 一直是一个争议功能。早期它被用于远程发布文章、移动客户端通信以及与其他平台的交互。
www.innnets.com
A Complete Guide on xmlrpc.php in WordPress (And How to Disable It)
Why does WordPress still have the xmlrpc.php file? Should you disable it for security reasons? Learn more about what xmlrpc.php is in this in-depth guide.
kinsta.com

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注