刚做的新网站,就发现有robot在采集,而很多采集插件都是针对feed的,所以关闭feed,可以在一定程度防止采集。
除了通过插件实现关闭feed,还有以下几种方法:
- 将以下代码复制到wordpress主题的functions.php中
//关闭rss feed功能
function disable_all_feeds() {
wp_die(__('<h1>本博客不提供Feed,请访问网站<a href="'.get_bloginfo('url').'">首页</a>!</h1>'));
}
add_action('do_feed', 'disable_all_feeds', 1);
add_action('do_feed_rdf', 'disable_all_feeds', 1);
add_action('do_feed_rss', 'disable_all_feeds', 1);
add_action('do_feed_rss2', 'disable_all_feeds', 1);
add_action('do_feed_atom', 'disable_all_feeds', 1);
2. 另外还需要注意的是wordpress还会在网页中生成feed地址,查看网页源码可看到,为了不让此内容显示,继续将以下代码复制粘贴到刚才的functions.php中
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );