FeedBurner lets you publicize, optimize, analyze, and monetize your RSS feeds – basically putting your standard RSS feed on steroids. You tell FB where it can find your blog feed (mine’s at http://adamstiles.com/feed/) and it produces a souped up version that can be downloaded from a FeedBurner URL (e.g. http://feeds.feedburner.com/adamstiles). Once you have this new feed URL, you just need to get your subscribers to download it from the new location. Easy enough for new subscribers, but what about existing ones? I want my stats to include all readers, not just existing ones.
A little WordPress background is in order. WP processes all pages on your blog, including your feeds, through a PHP file called index.php. It uses a couple of mod_rewrite rules to make this happen.
# Apache mod_rewrite rules that rewrite URLs from:
# OLD: http://adamstiles.com/feed/
# NEW: http://adamstiles.com/index.php?feed=feed
# OLD: http://adamstiles.com/feed/rss/
# NEW: http://adamstiles.com/index.php?feed=rss
# Etc… for rdf, rss2, atom
RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
Its important to get this to avoid a gotcha later. Your subscribers download your feed from a URL that looks like this http://adamstiles.com/feed/ but WP processes that request like this http://adamstiles.com/index.php?feed=atom. Your feed subscribers will use the first URL, even though WP uses the second internally. Nobody subscribes to the index.php?feed=atom version of your feed but we’ll use that when we tell FB where it can find your feed.
Now that that’s out of the way we can get started.
Step 1: Setup Your FeedBurner Feed
The first thing you need to do is tell FeedBurner where to find your feed. There is an important gotcha here – use a WP feed url with index.php in it, don’t use the rewritten WP feed URL. In my case, I told FB that my feed was located at http://adamstiles.com/index.php?feed=atom. FB now makes my souped up feed available at http://feeds.feedburner.com/adamstiles. The reason you need to tell FB to use the index.php url and not your rewritten URL is that we’re going to tell Apache to redirect subscribers to our old feed URL to the new FeedBurner URL. See the problem? If FB is grabbing the URL from the rewritten URL, but we’re redirecting the rewritten URL to FB, it gets caught in a loop and never actually gets any feed content. Make sure you’re using the index.php?feed=something URL when setup your account with FB.
Step 2: Redirecting Old Subscribers to the New URL
We’ll use some custom mod_rewrite rules to redirect feed readers from the old WordPress feed URLs to the new FeedBurner URLs. Modify the feed-related rules in your .htaccess file to redirect to FeedBurner.
# Replaced /index.php?feed=$1 with my FeedBurner URL
# The R in brackets tells apache that this is an external redirect
# The L means this is the last rule for processed for the URL
RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/adamstiles [R,L]
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/adamstiles [R,L]
I also updated some other rules that I originally setup when I moved to WordPress from TypePad:
RewriteRule ^adam/index.rdf$ http://feeds.feedburner.com/adamstiles [R,L]
After this, test the rules. Go to your old, rewritten feed url (e.g. http://adamstiles.com/feed/) in a browser and you should be redirected to your FeedBurner URL. FB will detect that you’re using a browser to display your feed and it will add some markup to it to make it easy to read (not just XML).
Step 3: Making Redirects Permanent
This step is optional but some will find it useful. At this point your redirects are temporary – feeds readers will still come to you first and they’ll be redirected to the FeedBurner URL each time. If you use a permanent redirect, many feed readers will update their subscription data so they go directly to the FB URL and don’t have to come to your first. To do this, you need to change your rule modifiers from [R,L] to [R=permanent,L].
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/adamstiles [R=permanent,L]