Articles,  Blogging,  WordPress

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.

(Visited 2,001 times, 1 visits today)

5 Comments

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.