|
|
Redirecting an existing RSS feed to Feedburner - Apache Webmaster Tips, Knowledge Base Webmaster Tools
| Home > Apache > Redirecting an existing RSS feed to Feedburner | |
| | Category | : Apache | | Written by | : Admin | | Date | : 2008-11-16 | | Rating | : 0 | Voted : 0 times | | Hit | : 33 | | | | |
| Feedburner can host an RSS feed for you and provide useful statistics about the readers. If you already have an RSS feed running locally on your site, you can change the feed location to a Feedburner one and set up permanent redirects in Apache so that existing readers will be counted by Feedburner. I did this recently for my Linux CD Mall website, because I was interested to see how many readers I have utilising the feed. Until moving the RSS feed to Feedburner I had no idea how many there were.
The first step is to create a new version of your site or blog's RSS XML file. For example, on my Linux CD Mall website, the existing RSS file was at /rss/news.xml. I created a new feed file called eg /rss/news-fb.xml and added the feed for the news-fb.xml file to Feedburner. Now whenever I update the RSS file, I update news-fb.xml and Feedburner reads the updated posts from there.
The next step is to set up redirects from the old /rss/news.xml (or whatever your RSS feed file is called) to the Feedburner location (in my case it's http://feeds.feedburner.com/linuxcdmall). This is really simple in Apache using either a RewriteRule or a RedirectPermanent directive.
In a <virtualhost> block in your main Apache configuration, using a rewrite directive, you need to specify the full absolute path with a leading slash if using pattern matching (the ^ to denote start of string and $ to denote end of string) as shown in the following example:
RewriteEngine On
RewriteRule ^/rss/news.xml$ http://feeds.feedburner.com/linuxcdmall [R=301,L]
When doing the above in a .htaccess file, you specify a relative path to the .htaccess file, and do not include a leading slash:
RewriteEngine On
RewriteRule ^rss/news.xml$ http://feeds.feedburner.com/linuxcdmall [R=301,L]
Using RedirectPermanent is the same for both a <virtualhost> block and an .htaccess file as follows:
RedirectPermanent /rss/news.xml http://feeds.feedburner.com/linuxcdmall
If you modify the Apache config then you need to reload Apache for the change to take affect. If using a .htaccess file the change will take affect as soon as you save/upload the file. Now any requests to /rss/news.xml will be served with a permanent redirect to the Feedburner request, as shown in the example headers returned below when using the CLI web browser lynx with the -dump and -head flags:
$ lynx -head -dump http://www.example.com/rss/news.xml
HTTP/1.1 301 Moved Permanently
Date: Thu, 20 Dec 2007 17:57:39 GMT
Server: Apache/2.2.4 (Linux/SUSE)
Location: http://feeds.feedburner.com/linuxcdmall
Connection: close
Content-Type: text/html; charset=iso-8859-1
Easy stuff!
You might ask why we don't just use the existing feed file for Feedburner insetad of creating a new file. The reason for this is that if you use the existing feed file, and set up a redirect from the existing file to the Feedburner address, Feedburner will never be able to access the old feed address: it will get redirected back to itself.
|
|