Redirecting your RSS traffic to Feedburner via mod_rewrite
So you host one or more blogs and discovered that serving the regular requests to your RSS feeds consumes a major share of your bandwidth? Good. Then you also heard of FeedBurner? Great. Then why not let FeedBurner answer the RSS requests?
Setting up a FeedBurner account is free and easy. But what if you alreday have tens of thousands of pleople subscribed to your RSS feeds?
If you host on the Apache Web Server, use mod_rewrite and have write access to your server configuration, here is a way how you can redirect the requests to your FeedBurner URL(s).
Complete apache configuration snipped:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} !(.*FeedBurner.*) [NC]
RewriteRule ^feed/.*$ http://feeds.feedburner.com/examplefdeed [R=301,L]
Explanation:
If you haven’t heard of Apache configuration, .htacces files and that stuff, you should start with the Apache documentation.
The code above does the following:
- Line 1 activates the mod_rewrite rewrite engine for this server or directory.
- Line 2 sets the base for URL parsing. Read all about this configuration directive in the mod_rewrite documentation.
- Line 3 sets a condition for URL rewriting. In this case, the rewriting shall only happen in case the HTTP_USER_AGENT contains the exact string FeedBurner. This is the case when FeedBurner comes to fetch your RSS feed. And is usually isn’t the case when other come looking for your RSS. The option [NC] makes this string comparison case insensitive.
- In line 4, the actual URL rewriting is configured. The first parameter describes which URL is currently used on your site in order to access the RSS feeds. As it’s written in the example, the pattern will match everything starting with /feed/, e.g. /feed/rss/, /feed/atom/. This is a convenience for wordpress users. The next parameter is the full URL to the according feed at FeedBurner’s. At the end, the options say that this should be a HTT 301 Redirect (301 means “moved permanently”) and the L makes this to be the last RewriteRule to be applied, just in case you have others in your configuration.
Now we redirect our feed requests to FeedBurner. The 1 Mio $ question is: When will Google FeedFetcher, Bloglines, Netvibes and all the other big RSS consumers plus the developers of RSS clients recognize? They continue requesting the original URL, thus issuing millions of unnecessary HTTP requests.
1 Comment
Your comment