Is it possible to remove feeds from rewrites?

I am using Monkeyman Rewrite Analyzer so I can see all rewrites when I am doing some custom rewrites and I have noticed that a lot of those rewrites are generated for feeds. Is there any way I can remove them? Does it affect performance? I have counted how many of these rewrite rules contain “rdf”, there are 90 and as my site grows there will probably be more so disabling only them I feel like it would clean a lot of garbage

Example

   myctp/feed/(feed|rdf|rss|rss2|atom)/?$   
   myctp/(feed|rdf|rss|rss2|atom)/?$

I have tried Disable Feeds plugin and this plugin (which is 5 years old) https://gist.github.com/chrisguitarguy/2223644, I didn’t noticed any difference

1 Answer
1

Why are you removing rewrite rules? These should not noticeably impact performance, unless there were thousands of entries.

Yes, you can remove them, but you will break any functionality associated with those urls, and you won’t improve your site’s speed at all. If you’re concerned about site speed, check out YSlow and Google Page Speed Insights instead.

If you’re dead set on removing rules, you can do that one of two ways.

  • If they are written into your .htaccess file, you can edit that and remove the rule. Be sure to backup .htaccess before doing this.
  • You could also remove anything added via wordpress hooks in your theme functions.php file, or a plugin. This code will run every time the page loads and (ironically) risk making your problem worse (though I’d bet it would still be unnoticeable). Check out the generate_rewrite_rules action to do that.

Here’s some sample code:

add_action('generate_rewrite_rules', 'my_remove_rules');
function my_remove_rules( $wp_rules )
{
    unset( $wp_rules->rules[ 'some_rule' ] );
}
  • If any of these rules are added by a plugin, you could also disable that plugin, and then make sure to flush your rewrite rules. You can flush (that is… re-create) your rewrite rules by saving the permalinks page under “settings” in wp-admin.

Good luck!

Leave a Comment