当前位置:首页>WordPress建站>网站安全>WordPress 正确移除 Feed 输出的 wellformedweb.org/CommentAPI 恶意网址

WordPress 正确移除 Feed 输出的 wellformedweb.org/CommentAPI 恶意网址

今天看到 im2828 反馈说,WordPress 源码引入的一个网址 http://wellformedweb.org/CommentAPI 的域名 wellformedweb.org 过期后被恶意抢注了,该网址会跳转到BC类网站(虽然我直接访问没有看到),有些服务器商已经通知用户进行处理。感谢 im2828 朋友!

WordPress 正确移除 Feed 输出的 wellformedweb.org/CommentAPI 恶意网址 - Remove Wfw Commentapi Link 1
问题反馈

这个 wellformedweb.org/CommentAPI 网址是用来做什么的?

wellformedweb.org/CommentAPI 最早用于 CommentAPI 规范,用来标准化 WordPress 等博客系统的评论接口。WordPress 很早就在 Feed 中硬编码了这个链接,并一直保留至今。

随着时间推移,wellformedweb.org 域名的原持有者不再续费。该域名已被从事非法业务的公司购买,现在的 wellformedweb.org 可能会跳转到赌博、色情等非法内容页面。

如何检查你的网站是否有这个问题?

最直接的检测方法就是在网站域名后面添加/feed 来访问,比如访问 https://www.wpdaxue.com/feed,如果你看到下面加框的这行,说明你的网站存在遗留问题:

WordPress 正确移除 Feed 输出的 wellformedweb.org/CommentAPI 恶意网址 - Remove Wfw Commentapi Link
通过访问 Feed 网址查看是否有问题

如何正确移除 wellformedweb.org/CommentAPI 在Feed中的输出?

其实,由于 wellformedweb.org/CommentAPI 并非显性输出到页面中,也无法直接点击访问,普通用户一般不可能访问到这个网址,在前端页面中,唯一可以通过网址访问和查看到 wellformedweb.org/CommentAPI 网址的也就是上面说的 Feed 网址的代码中。

这个 feed 网址可能会被一些蜘蛛爬行,至于到底 wellformedweb.org/CommentAPI 会不会被蜘蛛识别为恶意网址,甚至蜘蛛是否会爬行 wellformedweb.org/CommentAPI 都无法确认,但是出于安全合规考虑,我们还是移除它会好一些。

方法1:安装下面的插件或添加对应代码去移除【最佳方案】

最便捷方式: 点击下载插件 Remove WFW CommentAPI Link ,然后在后台 插件 – 安装插件 界面上传安装启用。

如果你不想安装插件,可以将下面的代码添加到你当前启用的主题的 functions.php 文件:

/**
 * Plugin Name: Remove WFW CommentAPI Link
 * Plugin URI: https://www.wpdaxue.com/remove-wfw-commentapi-link.html
 * Start output buffering on feed requests.
 */
function rwcl_feed_ob_start() {
	if ( ! is_feed() ) {
		return;
	}
	ob_start( 'rwcl_feed_ob_callback' );
}
add_action( 'template_redirect', 'rwcl_feed_ob_start', 0 );

/**
 * Output buffer callback: strip wfw-related content from the feed.
 *
 * @param string $output The buffered feed output.
 * @return string Modified feed output.
 */
function rwcl_feed_ob_callback( $output ) {
	// Remove the entire line containing xmlns:wfw (including leading newline and tab indentation) to keep XML formatting intact.
	$output = preg_replace( '/\n\t*xmlns:wfw="http:\/\/wellformedweb\.org\/CommentAPI\/"/', '', $output );

	// Remove <wfw:commentRss>...</wfw:commentRss> tags and any trailing whitespace.
	$output = preg_replace( '/<wfw:commentRss>.*?<\/wfw:commentRss>\s*/s', '', $output );

	return $output;
}

方法2:直接修改源代码 wp-includes\feed-rss2.php 移除加框代码【不推荐!】

不推荐此方法,因为你一更新WordPress就得重新修改

WordPress 正确移除 Feed 输出的 wellformedweb.org/CommentAPI 恶意网址 - 企业微信截图 17809126599053

无效的方法:有些教程说使用下面的代码,实际是无效的!

此方法毫无根据,根本就没有对应的filter钩子可以过滤,实测无效!!

WordPress 正确移除 Feed 输出的 wellformedweb.org/CommentAPI 恶意网址 - Image

好了,以上就是从Feed输出中移除 wellformedweb.org/CommentAPI 的解决方案。

关于这个过时网址何时会从 WordPress 源码中移除,我们不得而知。如果你的主机商还要求你直接删除源码文件中的相关代码,你可以查看以下两个文件:

  • wp-includes/feed-rss2.php 22行左右
  • wp-admin/includes/export.php 524 行左右
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
欢迎关注WordPress大学公众号 WPDAXUE
WordPress插件网站安全

使用 Captcha for WordPress 拦截垃圾邮件/评论/表单提交

2025-8-31 16:47:27

用户交互

给你的 WordPress 站点添加微信打赏功能

2015-11-6 15:05:11

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索