How to Redirect WordPress Feed to Feedburner Using .htaccess

Posted on In Web

.htaccess is a powerful tool. Let’s look at how to using .htaccess to redirect WordPress feeds to feedburner.

Let’s use my blog as the example. The WordPress’s feed url of my blog is https://www.systutorials.com/feed/. Now I want to redirect it to feedburner with url http://feeds.feedburner.com/systutorials .

The idea is quite straightforward: For every request to https://www.systutorials.com/feed/, first check whether the HTTP_USER_AGENT is FeedBurner or FeedValidator. If HTTP_USER_AGENT is one of these two feed burners, do nothing and so feeds from WordPress will be returned to the feed burner. Otherwise, redirect the request to http://feeds.systutorials.com/systutorials since it is from a normal user’s browser or feed reader. Through this method, the normal user can read the feeds from feedburner, while feedburner can get the original feeds from WordPress. We can also enjoy the other advantages of feedburner, such as tracking and statistical services.

The method
Add these codes to the beginning of the .htaccess file in the root directory of the site:

# Redirect WordPress feeds to feedburner
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_URI}      ^/?(feed.*|comments.*)        [NC]
 RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner)             [NC]
 RewriteRule ^feed/?.*$          http://feeds.feedburner.com/systutorials        [L,NC,R=302]
</IfModule>

Here the comments feed and posts feed are written together for convenience. Only the feedburner url need to be changed for other WordPress sites.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

7 comments

  1. Thanks for posting this article and it has been quite helpful in understanding few of the technicalities .
    However I am having some problems in redirecting multiple rss feeds to feedburner, as the feedburner is unable to show updated data .My .htaccess file looks like
    ———————————–

    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTP_USER_AGENT} !^(FeedBurner|FeedValidator) [NC]
    RewriteCond %{HTTP_USER_AGENT} .

    Redirect 302 /rss/abc.xml http://feeds.feedburner.com/www123com
    Redirect 302 /rss/def.xml http://feeds.feedburner.com/www123com
    Redirect 302 /rss/ghi.xml http://feeds.feedburner.com/www123com

    ————————————-
    The first redirect 302 is showing updated data and the rest are showing old data. It would be of great help if you could guide me on this.

    Thanks in advance
    Rahul

    1. Just one suggestion and you may have a try:

      Merge the three ‘Redirect 302’ together using regular expression like the one in the post ‘(feed.*|comments.*)’ .

      Hope it help.
      Eric

  2. If I redirect the feed to Feedburner, when the Feedburner request feed won’t WordPress enter into a eternal looping?

    Sorry if I asked something simple and the answer is obvious.

    1. This line:

      RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner) [NC]

      ensures that the feed URL is not redirected for the feedburner robots.

Leave a Reply

Your email address will not be published. Required fields are marked *