How to redirect wordpress feed to feedburner feed url

If you have been using wordpress for directly serving rss feed and have recently migrated to feedburner, then some of your users are still being server from old feed url. e.g. If you web site is infoheap.com, some of your users are being served from http://infoheap.com/feed/. While the new ones will get served from feedburner url which is either http://feeds.infoheap.com/infoheap  or http://feeds.feedburner.com/infoheap depending upon whether you are using My Brand feature of feedburner or not.

You may consider redirecting your old users to feedburner hosted feed url when they visit old rss feed url. We’ll look into two ways to do it.

Using wordpress feedburner plugin

One way to do it is using feedburner plugin which lets you redirect you old feeds url to new feedburner url for most user agents (except a few). Here is how the configuration looks like for this plugin:

wordpress-feedburner-plugin-confuguration

I think it is better to not redirect category, tag, author and search results feeds and directly serve them from wordpress site itself.

Some points to note:

  1. The plugin uses HTTP 302 redirect.
  2. The plugin does not redirect for Feedburner and Googlebot user-agents as per the following code (at the time of writing this article):
    // Do nothing if feedburner is the user-agent
    if (preg_match('/feedburner/i', $_SERVER['HTTP_USER_AGENT'])) return;
    
    // Avoid redirecting Googlebot to avoid sitemap feeds issues
    // http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=97090
    if (preg_match('/googlebot/i', $_SERVER['HTTP_USER_AGENT'])) return;
  3. It is simple to implement and does not require any apache config changes.

Using apache configuration

This is preferred way as it is faster than php based redirection (plugin approach). Here is the configuration you can use in apache conf file:

RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator|Googlebot) [NC]
RewriteRule ^/feed/?$ http://feeds.infoheap.com/infoheap [L,NC,R=302]

Some points to note:

  1. You will need mod_rewrite module enable for this.
  2. I used HTTP 302 here which is a temporary redirect. You can also choose HTTP 301. I decided a temporary redirect as this is more flexible and can be changed later. The small disadvantage is “HTTP 302” will result in more hits/load on your server.
  3. The redirect should not happen for Feedburner user-agent as Feedbuner will fetch feeds from your site itself to serve it to others users.
  4. We are not redirecting for FeedValidor user-agent in case you want to use FeedValidor to validate the feed.
  5. We are also avoiding redirect for Googlebot to avoid potential sitemap feeds issues. You can look at this google feedburner help page for more info. This is applicable only if you are using feed as a source of sitemap.
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments