How-To: Use .htaccess to redirect your Blog Feed to your Feedburner Feed

FeedBurner

FeedBurner provides an excellent feed service that lets you track how many users are subscribed to your feed and more.

Users can still bypass your FeedBurner feed and continue to subscribe to your original blog feed.

While this is not a problem, your stats may not give you slightly inaccurate number of your feed subscribers.

A good option is the WordPress FeedBurner Plugin, which will redirect all your feeds to Feedburner.

If you do not wish to use another plugin or if, like me, you are redirecting a category feed, (I got one for Connections Reloaded), then you can redirect your users by adding the following code to your .htaccess file. Replace AAAAAA by that of your feedburner feed.


# Redirect /feed/ to Feedburner (if not Feedburner bot)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/AAAAAA [R,L]
</IfModule>

Make sure you add this code before the section of the code added by WordPress. Otherwise your feed won’t be redirected.

The code explained:

The first line of the code is a comment.
The second line checks if mod_rewrite is installed. This is to ensure that your site doesn’t break.
The third line turns the RewriteEngine on. This is required before any rules are used.
The fourth line is extremely important. It ensures that the FeedBurner Bot is excluded from the redirection. If this line is missing your feed fetching will result in an infinite loop.
The fifth line redirects the /feed/ to your feedburner feed.
The last line is just a closing tag for the mod_rewrite check.

Share this post with your friends!

4 Comments

  1. Thanks for the code. I’m doing some research to accomplish a different project for my WordPress blog, and this not only gives me a better understanding of .htaccess, but I think I’ll add it in while I’m at it and get rid of the Feedburner Feedsmith plugin.

  2. Thanks for your code! I’ve been having problems with my feed during the last four days and your solution has worked with no problem, indeed, it’s easy and compact.

Comments are closed.

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.