mundell.org A little of this, a little of that

HOWTO use FeedBurner without giving up control

Update on June 1: There’s a new WordPress plugin that makes using FeedBurner a snap. There’s no need to manually edit .htaccess. The plugin takes care of all the redirect rules. I’m using it now and it’s working great. The method described below does work, however, I think the plugin is easier to use and more reliable.

Recent chatter on the notion that FeedBurner users are “playing with fire” has induced me to share some information on how to use FeedBurner without permanently giving up control of your feed. This HOWTO applies specifically to WordPress 1.5, but could be tailored for other systems. In fact, here’s a FeedBurner forum post that explains exactly how to redirect temporarily your Movable Type feed to FeedBurner.

My host uses Apache and mod_rewrite which are prerequisites to making the following method work.

WordPress makes extensive use of rewrite rules in an .htaccess file. You’ll find the .htaccess file in your blog root directory. You can make a few changes to .htaccess which will forward requests for your feeds to FeedBurner. The changes will allow only FeedBurner access to the source feeds. At any time in the future you wish to stop using FeedBurner, like if they go dark, just remove the rewrite rules from .htaccess.

In a default installation of WordPress, you’ll find lines in your .htaccess file that look like this:

RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L] RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]

Move these lines to the very end of .htaccess. Then edit so they look like the following:

RewriteCond %{HTTP_USER_AGENT} FeedBurner RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L] RewriteCond %{HTTP_USER_AGENT} FeedBurner RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L] RewriteCond %{HTTP_USER_AGENT} !FeedBurner RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/<em>insertyourfeednamehere</em> [R,L] RewriteCond %{HTTP_USER_AGENT} !FeedBurner RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/<em>insertyourfeednamehere</em> [R,L]

English translation: a request for any one of your site’s main feeds will be redirected to your FeedBurner feed except if the requester is the FeedBurner agent. Please note: replace insertyourfeednamehere with whatever your FeedBurner feed name is.

This has been working well for me. I hope it works well for you, too.


14 Comments

This works great for me with the exception of http://www.recycledcognition.com/rss, which fails to redirect for some reason. I have checked and double-checked that I have the code right, and it just doesn’t work even though the other variants do. But all of the /feed/* redirects work (including /feed/rss) so I don’t know what is happening. I tried mundell.org/rss, and it works for you so I’m not sure what’s up.

Posted by recog on 2 April 2005 @ 8pm

As a followup, the following works:

http://www.recycledcognition.com/rss

whereas it doesn’t work without the ‘www’

But that’s the only variant that requires the ‘www’

Weird.

Posted by recog on 2 April 2005 @ 8pm

Hmmm… I just rechecked the /rss link this morning, and it’s now forwarding as expected. I have no idea why it wasn’t behaving last night, but it wasn’t. But it’s all good now. Thanks!

Posted by recog on 3 April 2005 @ 10am

I’m glad it’s working for you.

Posted by Carrick on 3 April 2005 @ 1pm

[...] ter. In order to make sure that everyone was using the Feedburner feed, however, I had to edit the .htaccess file for both blogs, which was, well, painful. Plugins WordPress is a little like F [...]

Posted by Brainwidth » Up and Running? on 10 April 2005 @ 4pm

[...] mmunity/ru_wordpress/ FeedBurner VS WordPress http://codex.wordpress.org/Using_FeedBurner http://www.mundell.org/2005/03/26/216/ Leave a reply Name (Ð [...]

Posted by Ð?у и Ð?у! ру » ЧаÑ?ть 2 on 27 April 2005 @ 10am

I tried to employ your method on my site but it does not redirect. I also tried looking at your feeds and they come back as regular XML files, they do not redirect to Feedburner feeds. Did you turn the redirection off or is there a problem?

Posted by RWT on 19 May 2005 @ 3pm

One thing I’ve noticed is that WordPress will re-write your .htaccess file whenever you do something like add or edit a “page.” It does it at other times, too, which I haven’t quite figured out. It’s rather annoying to say the least, especially when it comes to the feed rewrites. What I do to compensate is keep a copy of my .htaccess for those times when WP feels the need to think for me. You can also keep the rewrite rules above in a handy text file to add to whatever new .htaccess rules WP devises for your particular setup. There’s probably a way to modify WP to get it to output the above rewrite rules automatically. I haven’t looked into that yet.

Posted by Carrick on 19 May 2005 @ 3pm

OK I found part of my problem. My permalinks use “index.php”. Thus, WordPress does not overwrite any .htaccess file. WordPress doesnt use the file if permalinks are set up as such. But my question is this, given that is the case what would be the correct way to formet the .htaccess to redirect for Feedburner? I am not that adept at writing .htaccess but I came up with the following, which is essentially what you have above, but I did include it within the WordPress #’s. Whats wrong?

Options All -Indexes

# BEGIN WordPress
RewriteEngine on
RewriteBase /rwt/
RewriteCond %{HTTP_USER_AGENT} FeedBurner
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
RewriteCond %{HTTP_USER_AGENT} FeedBurner
RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/myfeed [R,L]
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/myfeed [R,L]
# END WordPress

Posted by RWT on 20 May 2005 @ 2pm

Oh my wordpress feed then is:

http://www.mysite.com/index.php/feed/

Posted by RWT on 20 May 2005 @ 2pm

Hmm, I thought using the index.php prefix was for situations where you don’t have mod_rewrite? Are you sure your host uses mod_rewrite? It’s a prerequisite for the redirects above to work, and I mentioned that in the second paragraph.

I’m not quite sure how to solve your particular problem.

Posted by Carrick on 20 May 2005 @ 3pm

Yes they use mod_rewrite. Put the version of Apache is 1.3.33. The non-index.php way of doing permalinks does not seem to work with any version of Apache under 2.0.

Posted by RWT on 20 May 2005 @ 3pm

[...] ke it. I installed the FeedBurner plugin. I wish this had been available before I started messing around with my own redirect rules in .htaccess. This makes using FeedBurner with WordPress a snap. [...]

Posted by mundell.org » Not leaving well enough alone on 1 June 2005 @ 9pm

I think I found a simple work-around to RWT’s problem.

My host uses Apache 1.3.33. I made a redirect in cpanel from /wp-rss2.php to my feedburner feed.

To avoid feedburner getting caught up by the redirect, I just pointed it to http://www.mysite.com/?feed=rss2

Seems to be working like a charm.

Here’s what cpanel inserted into my .htaccess:
RedirectMatch temp ^/wp-rss2.php$ http://feeds.feedburner.com/insertfeedname

Posted by Nathan on 6 June 2005 @ 12pm