WordPress.org

Forums

Redirect Feeds to Feedbuner Without Any Plugin (9 posts)

  1. Suraj Vibhute
    Member
    Posted 3 years ago #

    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.

  2. david.bailey
    Member
    Posted 3 years ago #

    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');
  3. Suraj Vibhute
    Member
    Posted 3 years ago #

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

  4. James Kirk
    Member
    Posted 3 years ago #

    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!

  5. threestyler
    Member
    Posted 3 years ago #

    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>
  6. loughcorrib
    Member
    Posted 3 years ago #

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

  7. DIRPLANET
    Member
    Posted 2 years ago #

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

    DirPlanet

  8. Anoop M C
    Member
    Posted 2 years ago #

    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..

  9. Emphacy
    Member
    Posted 2 years ago #

    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);

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags