Welcome to the new design! Please report any bugs or issues, thanks :)
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/perishablepress [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/perishablepresscomments [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/perishablepress” and/or “https://feeds.feedburner.com/perishablepresscomments” 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/perishablepress         [L,NC,R=302]
 RewriteRule ^comments/?.*$      https://feeds.feedburner.com/perishablepresscomments [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>

Jeff Starr
About the Author
Jeff Starr = Web Developer. Book Author. Secretly Important.
WP Themes In Depth: Build and sell awesome WordPress themes.

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

  1. Good post, and thanks for the htaccess code.

    I’m a performance enthusiast myself, and couldn’t find any reason to keep FeedSmith when similar redirects are handled by htaccess. Only, I couldn’t get hold of the required code. Now I have :D

  2. Jeff Starr
    Perishable 2008/03/25 1:21 pm

    Thanks for the feedback, Sumesh! I am glad you found the code useful. It is amazing how many plugins are actually unnecessary for people who take the time to improve the performance of their site. One less plugin slowing things down is always a good thing! ;)

  3. Thank you, sheesh, you’d think that getting something like this set up was supposed to be a secret or something. Even the so called “how to’s” on the feed burner site are convoluted and difficult to follow… not to mention over 2 years old.

    This was easy to follow, understand and install.

    Thanks again!

  4. Jeff Starr
    Perishable 2008/04/20 7:49 am

    I totally agree, Evan — trying to decipher the Feedburner documentation for this technique is like driving without a car, somehow terribly futile and frustrating. And that is precisely the reason for this article. I am glad you found it useful! Thanks for the feedback :)

  5. Thanks! But this .htaccess may be applied to other non-wordpress feeds for redirecting to feedburner.

  6. Jeff Starr
    Perishable 2008/05/05 7:10 am

    Yes, the redirect technique described in the article could very well be adapted to non-WordPress sites (i.e., WordPress is not required for them to work). So long as the rewrite directives target the correct URLs, this method should prove most effective. Thanks for the reminder!

  7. Sumesh from Blog Creativity 2008/05/12 9:34 pm

    I have a couple of doubts –
    1) Can this be used for WP 2.5? (FeedSmith doesn’t work for 2.5 anyway)

    2) Should I place this code before or after the WordPress rules?

  8. Jeff Starr
    Perishable 2008/05/13 9:20 am

    Hi Sumesh, I have not yet tested this method with WordPress 2.5, but I think it will work just fine. As far as I know, WP 2.5 still uses the same permalink structures as previous versions. The FeedSmith plugin uses PHP to handle the feed redirects, and thus may not work if WP 2.5 has changed the PHP mechanism by which canonical redirects are produced. Conversely, the htaccess method should not be affected by such changes as it operates independently of PHP scripts (generally speaking). In any case, the best way to find out is to upload a copy (place anywhere in root/blog htaccess) and give it a shot. Good luck! ;)

  9. Thanks for the snippet.
    I had to place the code before the wordpress permalink rules. It didn’t work after the wordpress rules.

  10. Jeff Starr
    Jeff Starr 2008/08/03 7:44 am

    Thanks for the tip, Florian! :)

  11. Thank you! Feedburner’s been ticking me off, not updating right, for a while. I had to turn off Bad Behavior, fix the .htaccess, then change the feed, and THEN it worked. Sheesh. I’m tempted to go back.

    FYI, I also added in |rss.* to the REQUEST_URI line, and duped the rewrite for ^feed as ^rss to get site.com/rss to redirect too. Wicked easy!

  12. Jeff Starr
    Jeff Starr 2008/09/24 2:29 pm

    Thanks Ipstenu, glad to hear you got it working.. also, matching and redirecting rss is keen — thanks for the tip!

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
Playing the long game.
They have weaponized the idiots.
Good software never steals focus from the user. Even during startup.
After 10 years running my own business, I still manage schedules and tasks using old school post-it notes, sometimes simple sometimes very elaborate.
You know those sites, where you're trying to just grab a quick bit of information but the page is shifting all over the place as it loads up 3 million advertisements.
Selling two of my top WordPress domains, wp-zen.com & zen-wp.com $300 for both. Aged 9 years. Drop a line if interested.
Never force your users to type out a password (or any long string of characters) by blocking the paste function. Typing long strings leads to MORE errors than simple copy/paste.