Return 404 for any Wordpress's feed/rss

admin

Administrator
Staff member
I'm trying to force return 404 if url matches
Code:
"feed"
:
Code:
http://example.com/wordpress/?feed=rss2

I added
Code:
RedirectMatch ^(.*)feed(.*)$ [R=404]
to .htacess but it doesn't return any 404 error.

For Wordpress in functions.php I can use next code:

Code:
function fb_disable_feed() {
    include( get_query_template( '404' ) );
    header('HTTP/1.0 404 Not Found');
    exit; 
}
add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);

But it redirects
Code:
http://example.com/wordpress/?feed=rss2
(301) to
Code:
http://example.com/wordpress/feed
and only then it returns 404 error.

I need that
Code:
http://example.com/wordpress/?feed=rss2
would return 404 error & not redirect to
Code:
http://example.com/wordpress/feed