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

这个 wellformedweb.org/CommentAPI 网址是用来做什么的?
wellformedweb.org/CommentAPI 最早用于 CommentAPI 规范,用来标准化 WordPress 等博客系统的评论接口。WordPress 很早就在 Feed 中硬编码了这个链接,并一直保留至今。
随着时间推移,wellformedweb.org 域名的原持有者不再续费。该域名已被从事非法业务的公司购买,现在的 wellformedweb.org 可能会跳转到赌博、色情等非法内容页面。
如何检查你的网站是否有这个问题?
最直接的检测方法就是在网站域名后面添加/feed 来访问,比如访问 https://www.wpdaxue.com/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就得重新修改

无效的方法:有些教程说使用下面的代码,实际是无效的!
此方法毫无根据,根本就没有对应的filter钩子可以过滤,实测无效!!

好了,以上就是从Feed输出中移除 wellformedweb.org/CommentAPI 的解决方案。
关于这个过时网址何时会从 WordPress 源码中移除,我们不得而知。如果你的主机商还要求你直接删除源码文件中的相关代码,你可以查看以下两个文件:
wp-includes/feed-rss2.php22行左右wp-admin/includes/export.php524 行左右




