WordPress.org

Support

Support » WP-Advanced » Redirect Feeds to Feedbuner Without Any Plugin

Redirect Feeds to Feedbuner Without Any Plugin

  • Hey there,

    Could you please tell me, how to redirect WordPress’s default feed to Feedbuner without using .htaccess or any plugin. Thank you. Any help would be highly appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Drop this into your functions.php file:

    // Redirect RSS to FeedBurner //
    
    function diww_rss_feed_redirect() {
        global $feed;
    
        $new_feed = 'http://feeds.feedburner.com/wanderingbrit';
    
        if (!is_feed()) {
                return;
        }
        if (preg_match('/feedburner/i', $_SERVER['HTTP_USER_AGENT'])){
                return;
        }
    
        if ($feed != 'comments-rss2') {
                if (function_exists('status_header')) status_header( 302 );
                header("Location:" . $new_feed);
                header("HTTP/1.1 302 Temporary Redirect");
                exit();
        }
    }
    
    add_action('template_redirect', 'diww_rss_feed_redirect');

    hey David, thank you so much. you saved my day. You truly a rockstar. thank you so much again. God Bless!

    Nice! Thanks for asking this question, suraj78. That was something on my list to get out of the plugins list and into my functions. Figured I’d just have to rework the FD Feedburner, but this look nice and clean. 10,000 Grazis david.bailey!

    Can also be done via .htaccess (place before WordPress rewrite rules):

    <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{REQUEST_URI} ^/?(feed.*|comments.*) [NC]
     RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]
     RewriteRule ^feed/?.*$ http://feeds.feedburner.com/username [L,NC,R=302]
     RewriteRule ^comments/?.*$ http://feeds.feedburner.com/username [L,NC,R=302]
    </IfModule>

    David,
    Thanks for the code. I will give it a lash great to save on plugins.
    Thanks SAgain

    David, thank you so much, This Will Really Help Me

    DirPlanet

    Do not use the above given htaccess to redirect feeds to feedburner. It will also redirect any url starting feed. For example if you have a page with slug feedback it will be redirected to the feedburner url. Better you use the conditional tag is_feed(), first answer..

    I would recommend sticking to WordPress’ methods. http://codex.wordpress.org/Using_FeedBurner

    function feedburner_feed($output, $feed)
    {
        if (strpos($output, 'comments'))
        {
            return $output;
        }
        return esc_url('http://feeds.feedburner.com/yourID');
    }   add_action('feed_link', 'feedburner_feed', 10, 2);
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Redirect Feeds to Feedbuner Without Any Plugin’ is closed to new replies.