Home » Web

How to redirect WordPress feed to feedburner using .htaccess

By: Zhiqiang Ma On: Feb 21, 2010 Views: 47 No Comment Print Email
Tags: , ,

.htaccess is a powerful tool. Let’s look at how to using .htaccess to redirect WordPress feeds to feedburner.

Let’s use my blog as the example. The WordPress’s feed url of my blog is http://pkill.info/b/feed/. Now I want to redirect it to feedburner with url http://feeds.feedburner.com/pkill.

The idea is quite straightforward: For every request to http://pkill.info/blog/feed/, first check whether the HTTP_USER_AGENT is FeedBurner or FeedValidator. If HTTP_USER_AGENT is one of these two feed burners, do nothing and so feeds from WordPress will be returned to the feed burner. Otherwise, redirect the request to http://feeds.feedburner.com/pkill since it is from a normal user’s browser or feed reader. Through this method, the normal user can read the feeds from feedburner, while feedburner can get the original feeds from WordPress. We can also enjoy the other advantages of feedburner, such as tracking and statistical services.

The method
Add these codes to the beginning of the .htaccess file in the root directory of the site:

# Redirect WordPress feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_URI}      ^/?(feed.*|comments.*)        [NC]
 RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner)             [NC]
 RewriteRule ^feed/?.*$          http://feeds.feedburner.com/pkill        [L,NC,R=302]
</IfModule>

Here the comments feed and posts feed are written together for convenience. Only the feedburner url need to be changed for other WordPress sites.

Referrence:

http://perishablepress.com/press/2008/03/25/redirect-wordpress-feeds-to-feedburner-via-htaccess-redux/

Update history:
May 18, 2010. Change feed address. No redirect only for FeedBurner.

Read more:

Digg del.icio.us Stumble Techorati Facebook Newsvine Reddit Twitter
Mixx LinkedIn Google Bookmark Yahoo Bookmark MySpace LiveJournal Blogger RSS feed

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.