Transparently outsourcing your RSS feeds to Feedburner
MassWrestling.com gets about 90k requests to its RSS feeds every month, which eats up about 3GB of bandwidth transfers and puts extra load on the web server.
I saw a tip on Coding Horror Blog that it is a great idea to rewrite your RSS feeds to be syndicated by Feedburner. Unfortunately, the example given doesn’t quite work for MassWrestling.com’s e107 feed URLs:
/cms/e107_plugins/rss_menu/rss.php?forumposts.2
So I spent some time relearning Apache’s mod_rewrite, and came up with the following lines to add to my .htaccess files:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteCond %{QUERY_STRING} ^forumposts\.1$
RewriteRule ^rss\.php$ http://feeds.feedburner.com/masswrestling/posts_rss? [R=301]
This rewrite sends all requests that are not FeedBurner’s http agent to Feedburner’s copy of my feed. The problem was figuring out that the question mark after the rss.php? is actually not matchable in the RewriteRule condition. Instead, you have to match it in a RewriteCond against the %{QUERY_STRING} variable. The replacement pattern requires a question mark at the end of it to ensure that mod_rewrite does not pass on the extra paremeters to the new URL.
So now:
rss.php?forumposts.2
redirects (301, permanently moved) to:
http://feeds.feedburner.com/masswrestling/posts_rss2
Let’s hope it knocks out the extra RSS traffic I have.
This post is filed under Computer Science, MassWrestling. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
July 23rd, 2009 at 7:19 am
[...] This code is inspired by the one written by Mike Atlas, who had a similar issue and wanted to outsource his e107 forum RSS feeds to FeedBurner. [...]