WordPress.org

Ready to get started?Download WordPress

Forums

Use .htaccess to prevent feed access? (2 posts)

  1. tirussell
    Member
    Posted 3 years ago #

    My server cpu load spikes like crazy when my feeds are accessed, to the point of making the server unresponsive. I use WP (multisite, path-rewrite not subdomain) as a CMS, so I am not terribly interested in the feeds, and I'd just like to turn them off.

    Is it possible to rewrite the WP multisite .htaccess rules to prevent */feed/ from ever being accessed?

    I tried the following functions.php fix, but apparently the hooks kick in too late to prevent the spikes, so I'm thinking .htaccess is a higher-priority kill-switch.

    /**
     * Disable feeds
     */
    
    function fb_disable_feed() {
        wp_die( __('No feed available, please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
    }
    
    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);
  2. tirussell
    Member
    Posted 3 years ago #

    I think this might be what I am looking for - seems to work, but please let me know if this is a bad idea for any reason.

    in .htaccess:

    #Forbid all feeds
    RewriteRule ^feed\/ - [F]
    RewriteRule \/feed\/ - [F]

Topic Closed

This topic has been closed to new replies.

About this Topic