Latest Tweets404 Fix: Block Nuisance Requests for Non-Existent Files:…
Perishable Press

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-]+)?/?$ [R=302,NC,L]

# 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-]+)?/?$ [R=302,NC,L]

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 “” and/or “” 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/?.*$         [L,NC,R=302]
 RewriteRule ^comments/?.*$ [L,NC,R=302]

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.


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.
61 responses
  1. Marty Martin November 25, 2008 @ 8:00 am

    I’d like to be able to redirect the main blog and comments to feedburner, but preserve the WP RSS feed for my tags. Right now though, if I try to visit the RSS feed for a specific tag, it redirects me to feedburner’s main content feed for my site. I’m not much of a REGEX person. How would I accomplish this?

    A sample template RSS would be –

    Thanks for any suggestion!

  2. Jeff Starr

    @Marty Martin: Here is the code I use for this, placed directly before the WordPress permalink directives:

    # REDIRECT MAIN AND COMMENT FEEDS TO FEEDBURNER <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC] RewriteRule ^feed/?$ [L,NC,R=302] RewriteRule ^comments/feed/?$ [L,NC,R=302] </IfModule>

    Replace the yourmainfeed and yourcommentfeed with your main feed and comment feed, respectively. Upload to your blog’s root htaccess file and you should be good to go!

  3. Great tutorial, however I would like to redirect all my category feeds through feedburner, say I already had the feedburner feed created for each category, would inserting redirects for all my categories on the .htacces slow down my page loading?

    I asume the process for the categories RSS is the same as for the content and comments redirection, say I have a “Google” category, I assume wildcards are usable here (newbie modifiyng an .htacces ^^)

    The google feed is:

    So on the REQUEST_URI I could modifiy it like this so it would permit all my categories:

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

    And the redirect would be something like:

    RewriteRule ^category/google/feed/?.*$ [L,NC,R=302]

    So the whole thing would be like:

    # temp redirect all wordpress feeds to feedburner RewriteEngine on RewriteCond %{REQUEST_URI} ^/?(feed.*|comments.*|category/*/feed.*) [NC] RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC] RewriteRule ^feed/?.*$ [L,NC,R=302] RewriteRule ^comments/?.*$ [L,NC,R=302] RewriteRule ^category/google/feed/?.*$ [L,NC,R=302]

    Would be really helpful if anyone could check this for me, before I modify the .htacces
    Thank you.

  4. Jeff Starr

    @Alexander: Firstly, depending on the number of categories you have, implementing htaccess redirects for each of them should result in no noticeable difference in page-loading times. Each directive included in your htaccess file(s) does require an extra bit of processing, but unless you have an large number of categories (or a slow server), performance should not be affected by much.

    Secondly, when it comes to htaccess, a wildcard operator is specified by a literal dot ( . ), which will match any character in the target string. Further, to match any number of any type of character, an asterisk ( * ) is placed after the dot, like this: ( .* ).

    Lastly, the example RewriteCond that you specify will match against category feeds even without the extra expression, “category/*/feed.*”, due to the presence of the first “feed.*” statement. That is, any string matched by the second expression will also be matched by the first.

    Other than that, it looks like your code will work just fine, although I haven’t tested it for myself, so I am hesitant to say for sure. Just remember to change the feed URLs to yours instead of mine! ;)

  5. Thanks for the heads up!
    I actually tested it and it worked fine, I also followed your advice and removed the condition and everything well, also no noticeable slow down.

    Thank you.

    PD: Although in an ironic twist of fate I stopped using feedburner in the morning due to bad service by them. :P

  6. Hello! This is a great tip for redirecting feeds… I am hoping there is a way to use the rewrite when using “Domain Mirror” — having two domains on the same WP install.

    Is there some way to change ^feed/?.*$

    To be like ^*$
    and ^*$

    Is it as simple as that? Or does the ^ character mean something else?

    I’d appreciate any insight on this, thanks.

    – Michael

  7. Jeff Starr

    @Michael: The carat symbol ( ^ ) is used to denote the beginning of a string. It essentially says, “begin your pattern match at this point.” I am not familiar with “Domain Mirror,” but I understand the concept. Assuming both domains are located on the same server, the modified redirect code may indeed be as simple as you suggest, although I have not tested myself. Use caution when testing, of course. ;)

  8. Thanks for posting this. It got me 90% of where I wanted to be…

    The problem I needed to solve after migrating from Blogger to WordPress was redirecting subscribers from (the old Blogger feed) to

    So I was adding a rule like:

    RewriteRule ^feeds/posts/default$ [L,NC,R=301]

    But the rules above were firing instead, because “?” is a special character that means “match 0 or 1 of the preceding” thus “feed/?.*” matches “feeds…” and steals my redirect.

    I think what you really want is:

    RewriteRule ^feed/[?].*$ [L,NC,R=302]

  9. Jeff Starr

    @Brian St. Pierre: Yes, this technique is designed to redirect WordPress-formatted feeds to their Feedburner counterparts. Adjustments may be required to account for the subtle differences in syntax for alternate feed URLs (e.g., Blogger feeds). For WordPress, however, the method is sound, and used successfully on many sites.

    As for the literal question mark, it is not used in this technique as we are targeting permalink-formatted WordPress feeds. The optional match character (“?”) is used primarily to account for the presence (or absence) of a trailing slash on the feed URL(s).

    For redirecting non-permalink WordPress feed URLs, we target the various query strings themselves rather than using a literal question mark (as described in your comment). For more information on this, check out this article.

  10. I’m using FeedBurner and the Feedsmith plugin for my filter blog, DesiPundit. I found your post via the WordPress page for RSS feeds and this definitely looks much better.

    But I’ve a question. I have three sections on my blog; Community where I present (in excerpt form) syndicated feeds from other veteran bloggers, New & Upcoming where I link to posts from bloggers not in the first section with a short personal description of the link, and finally Featured which is kinda the best of the first two sections. Now my problem is that I want to offer full feeds but if I do, the posts in the first section show full feeds of the bloggers that I syndicate which may not be right as I want readers to click through to their blogs. But I don’t mind showing full feeds for the second section which is a short description of the link anyway and readers do click thru.

    So my question is, how do I offer partial feeds for one main category and its sub-categories while offering full feeds for the other category? The sections are defined by three parent categories. I would really appreciate if anyone has a solution.

  11. I was trying to get this to work for a few hours, didn’t quite redirect in the end. How can I just redirect the main feed to (domain/feed) to the feedburner feed? So I can still use all the other feeds for individual purposes?
    Cheers and have a great evening

  12. Hi Jeff, same here! It seems your blog always holds the answers to some of my questions :)
    Thanks for the fast response. I think I tried everything but it never redirects anything. I just put it in the httaccess right? Maybe below # END WordPress or fo i put it in there?
    Cheers Simon

[ Comments are closed for this post ]