Spring Sale! Save 30% on all books w/ code: PLANET24
Web Dev + WordPress + Security

Redirect WordPress Feeds to Feedburner via htaccess (Redux)

In a previous article, I explain how to redirect your WordPress feeds to Feedburner. Redirecting your WordPress feeds to Feedburner enables you to take advantage of their many freely provided, highly useful tracking and statistical services. Although there are a few important things to consider before optimizing your feeds and switching to Feedburner, many WordPress users redirect their blog’s two main feeds — “main content” and “all comments” — using either a plugin or directly via htaccess. Here is the htaccess code as previously provided here at Perishable Press:

# temp redirect wordpress content feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^feed/?([_0-9a-z-]+)?/?$ https://feeds.feedburner.com/yourfeedname [R=302,NC,L]
</IfModule>

# temp redirect wordpress comment feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
 RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
 RewriteRule ^comments/feed/?([_0-9a-z-]+)?/?$ https://feeds.feedburner.com/yourfeednamecomments [R=302,NC,L]
</IfModule>

The first code block redirects main content feeds to Feedburner, while the second block does the same for the main comments feed. The only editing required for either of these redirects is for the Feedburner URL itself; that is, edit the “https://feeds.feedburner.com/yourfeedname” and/or “https://feeds.feedburner.com/yourfeednamecomments” to match your own address. With this htaccess code in place, your feeds will be redirected to Feedburner for everyone except FeedValidator (or whichever feed-validation service you are using, edit code to match its user agent) and of course Feedburner itself. To add additional exceptions to the redirect, simply replicate either line containing RewriteCond, and edit the user agent (e.g., FeedBurner) to suit your needs. Of course, if you plan on using both of these redirects (i.e., all content and comment feeds), continue reading for a better technique..

New and Improved Method for Redirecting WordPress Feeds to Feedburner

For those of us using Feedburner for all content and comment feeds, we have consolidated the previous htaccess code into a single redirect. Additionally, we improve functionality by verifying the requested URI and simplifying the regex used to match the target string. Check it out:

# temp redirect all wordpress feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_URI}      ^/?(feed.*|comments.*)        [NC]
 RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC] 
 RewriteRule ^feed/?.*$          https://feeds.feedburner.com/yourfeedname         [L,NC,R=302]
 RewriteRule ^comments/?.*$      https://feeds.feedburner.com/yourfeednamecomments [L,NC,R=302]
</IfModule>

If you are redirecting both content and comment feeds, this “new and improved” htaccess code will do the job nicely. With optimized code and improved functionality, it is definitely recommended over the previous directives. Simply edit the URLs in the last two lines to match your own Feedburner addresses (one for posts and the other for comments), and place the code into your blog’s root htaccess file. No other changes should be required. Once the code is in place, test that everything is working by accessing your feed directly using its default (i.e., non-redirected) URL. After that, you can sit back, relax, and enjoy all the benefits of WordPress, Feedburner, and one less plugin to worry about.

Update

If either of your feeds will not redirect using the “new and improved” redirect code, try commenting out the following line:

RewriteCond %{REQUEST_URI} ^/?(feed.*|comments.*) [NC]

..and that should do the trick. Or, another option is to use the two “original” redirects provided in the beginning of this article.</update>

About the Author
Jeff Starr = Designer. Developer. Producer. Writer. Editor. Etc.
WP Themes In Depth: Build and sell awesome WordPress themes.

61 responses to “Redirect WordPress Feeds to Feedburner via htaccess (Redux)”

  1. Very nice tutorial. I use this method to redirect my blog feed to feedburner and it works perfect. Thanks!

  2. David Young 2010/03/07 3:25 pm

    I’m still a little confused about all this…

    I’ve got the .htaccess file updated, when I go to my site’s feed url (samplesite.com/feed) it redirects to the FeedBurner URL (feeds.feedburner.com/samplesite) and then takes me to the FeedBurner page that prompts me subscribe to the feed. But… if I look at the URL it will subscribe to, it points to the FeedBurner URL, not my site’s URL:

    http://fusion.google.com/add?feedurl=http://feeds.feedburner.com/samplesite

    Which seems to make people subscribe to the feedburner url – not my url.
    Am I doing something wrong?

  3. @David: If I understand you correctly, I think that’s just how it’s supposed to work. Once you setup the redirect, the Feedburner URL will be the one that is used when people subscribe to your feed. You can use your site’s original feed URL in the various “Subscribe to” links around your site, but once someone clicks on one of them, it will be redirected to the Feedburner URL. I hope this makes sense. You can read more about it here: Serve Yourself: Why Feedburner Needs a Feed Fix.

  4. David Young 2010/03/09 5:58 pm

    Hi Jeff-

    Thanks for the reply.

    I think I found the answer to my problem.

    My issue was that I didn’t want people to ever subscribe to my FeedBurner feed. That way, if for some reason I stopped using FeedBurner I wouldn’t loose my subscribers.

    The solution was, in addition to your .htaccess redirect — to on the FeedBurner page, go to Optimize -> Browser Friendly and then in the area where it asks “Are you redirecting your feed traffic?” click on the link below and enter my website feed url into the “Redirected Feed URL” field.

    This way, even though they use feedburner, and it tracks my subscribers – their feed url is still pointing to my original site’s url.

  5. David, very nice! That must be a newer feature, because it didn’t exist when I was cutting my own path through this territory a couple of years ago. It looks like it only works with the “BrowserFriendly” feed format, but it’s certainly nice to see Feedburner provide this functionality to their users.

    Thanks again — I’ll be trying it out and sharing my discoveries here at Perishable Press.

  6. Hello ,

    This is quite a useful tips for wordpress theme to change original rss url.

    But it didn’t work on my own theme .weird ! mm

    I have no idea but after changing .htaccess file with the code above and click

    through the rss on the theme itself and the ulr is still http://#####.com/feed

    the rss icon is at the footer part on my theme .And I have checked the

    footer.php and found it was encryption .Is that why it can not be redirected?

    Is there any sugesstion?

  7. Jeff Starr 2010/03/20 9:09 pm

    @wencent: Not sure, but keep in mind that we are only redirecting URL requests here. No changes will be made to any of your code, so you will need to do that yourself (using either URL is fine).

  8. Thanks so much for this! This was exactly what I was looking for (and surprisingly so hard to find)!

  9. So does this solve the problem of switching existing RSS subscribers using the default WordPress RSS feed URLs (from before you implemented FeedBurner) to using the FeedBurner feeds? One of my concerns with implementing FeedBurner was that it would only capture new subscribers because existing subscribers would have no reason to update their feeds to the new FeedBurner URL. Please let me know. Thanks!

  10. Jeff Starr 2010/05/03 1:10 pm

    Hi Dan, yes, using the htaccess method, any requests for either your actual feed URL or its Feedburner counterpart will be redirected to the Feedburner feed.

  11. Matthew Snider 2010/05/10 1:21 pm

    Has anyone noticed a slow show up on google reader after doing this? My feed updates within minutes if not sooner BUT in google reader it sometime shows hours later – it’s very very weird and basically a pain in the butt for my readers.

    I have things that I posted 4 hours ago and still nothing.

  12. Jeff Starr 2010/05/12 8:01 am

    Hi Matthew, you may need to ping Feedburner to reset/rebuild your feed:

    http://www.feedburner.com/fb/a/ping

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
WP Themes In Depth: Build and sell awesome WordPress themes.
Thoughts
I live right next door to the absolute loudest car in town. And the owner loves to drive it.
8G Firewall now out of beta testing, ready for use on production sites.
It's all about that ad revenue baby.
Note to self: encrypting 500 GB of data on my iMac takes around 8 hours.
Getting back into things after a bit of a break. Currently 7° F outside. Chillz.
2024 is going to make 2020 look like a vacation. Prepare accordingly.
First snow of the year :)
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.