Redirect WordPress feed to Feedburner

Update (21-02-2010): I become tired testing Feedburner for recursive redirection problem. I need to wait for feedburner's FeedBulletin for my account. and It does not come to check as and when you say to do so.  So, I have got a smart solution which can get me what I want (redirect all kind of feed [including Categories and tags]) to feedburner.

Here is my solution:

  • First use feedsmith Feedburner plugin.
  • Implement this .htaccess code:
    RewriteRule ^category/[w-]+/feed  http://feeds.feedburner.com/satya-weblog/scripting [L,NC,R=302]
    RewriteRule ^tag/[w-]+/feed  http://feeds.feedburner.com/satya-weblog/scripting [L,NC,R=302]

    This code should come before WordPress redirect code (# BEGIN WordPress ... # END WordPress).

  • That is all.

Advantage of this redirect solution:
This does not use expensive RewriteCond + RewriteRule. This is not very costly for a single request. but think of each request, Apache need to understand the request for the above condition. Now, my solution will only rewrite the rule if Apache found the request with one matching pattern. In RewriteCond + RewriteRule case, Apache process each RewriteCond then goes to RewriteRule and then if it find RewriteRule good then it checks with each RewriteCond again.
In the solution I have proposed, it only check for the categories and tags feed and redirect to normal feed. If you want to provide separate feed for each category then you need to burn feeds for categories and tags and use this kind of redirect.
Google also support FeedBurner_FeedSmith_Plugin.


Update: Sorry Dear, I have not tested the solution correctly. Feedburner is not able to read the feed correctly with the below solution. So, I need to check with it.
I am getting this error:
Error getting URL: 400 - Recursive feed redirection error: Are requests for your 'Original Feed' address — the feed that FeedBurner is checking for updates — being redirected to your FeedBurner feed? Make sure your Original Feed is provided from a web address that isn't redirected to FeedBurner.
I will update this page latter when I have corrected the error. Thanks.


I am trying to make sure all feed redirect to feedburner. So that I can count feed subscription number. But every time I see some loophole. and all solutions I have tried before was not perfect. I got feedsmith plugin very early and it redirect all basic feed to feedburner, so I have used it. WordPress has many kind of feeds URLs -

http://www.satya-weblog.com/feed/
http://www.satya-weblog.com/feed/rss/
http://www.satya-weblog.com/feed/rss2/
http://www.satya-weblog.com/feed/rdf/
http://www.satya-weblog.com/feed/atom/

and, you may want to redirect all feeds URLs to one location. That may be feedburner feed URL. These basic feed URLs were working well with WordPress feedsmith plugin but today I saw Wordperss has category feeds also: http://www.satya-weblog.com/category/lamp/feed.
I also saw some other problem (or missing solution) for the reason I have installed it (feedsmith) earlier but I do not remember. May be only this one was the error!
After seeing today's Category feed and that is not redirecting, I thought to remove the feedsmith plugin and try something else. Earlier I have tried other solution using Apache .htaccess config redirect but possibly due to the mentioned plugin was installed all failed. So, today I have deactivated it before trying anything else.

In today's search for the solution, I got perishablepress.com on top of the search page and I thought to try this. The code written there is:

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

It actually check whether mod_rewrite module is installed or not. If it is available then Switch On rewrite Engine and look for Request URL and then based on Condition redirect it to feedburner URL.
I do not know why it uses 302 redirect (temporarily redirect) but I have used 301 redirect (permanent). My rewrite engine was already ON as I had RewriteEngine on on the .htaccess page on top. So, no need to check for rewrite engine is on or not.
Here is my version of .htaccess code for feed redirect. You will see I have added one more line there, I will tell the reason latter.

# if this line is not on your .htaccess
RewriteEngine on
RewriteCond %{REQUEST_URI}      ^/?(feed.*|comments.*)        [NC]
RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]
RewriteRule ^feed/?.*$          http://feeds.feedburner.com/satya-weblog/scripting [L,NC,R=301]
RewriteRule ^comments/?.*$      http://feeds.feedburner.com/CommentsForWebScripting [L,NC,R=301]
RewriteRule feed$          http://feeds.feedburner.com/satya-weblog/scripting [L,NC,R=301]

The first line about RewriteEngine is not required if it is there in your .htaccess and that should not be within any condition (<ifModule ...>). If it is there but inside condition then you need to mention it again.
The last line is for the any other feed URL. As I said, I have found Category feed in WordPress and I want to keep track of it also. so, I have added the last line. With that line, all other feed will be redirected to normal feed. If you want to redirect all category feed to respective feedburner category feed then you need to burn each category feed in feedburner and then mention that in .htaccess. I do not want to apply this much effort so I have invented this method. Line 6 is your normal feed and line 7 is your comment feed. I have burned Feedburner feed using http://www.satya-weblog.com/feed URL and Comment feed is burned using http://www.satya-weblog.com/wp-commentsrss2.php in feedburner.

For each category you need to add a new line to above code like this:

RewriteRule ^category/lamp/feed/?.*$ http://feeds.feedburner.com/satya-weblog/lamp [L,NC,R=301]
Comments are open for an year period. Please, write here on Facebook page.