Feedburner and Textpattern

— Topic: Content Management

Update: You should point Feedburner to your /?atom=1& URL and not /?rss=1&, because the default RSS version 0.92 that Textpattern outputs gives an insufficient amount of data to Feedburner, namely the date and time articles are posted. Then, just go to OptimizeSmart Feed and and activate it. This will pare down the feed to whatever version of RSS your reader likes, without sacrificing the robustness of Atom for those who prefer it.

If you are reading this article via a news aggregator, then my .htaccess tomfoolery worked, and I have seamlessly transitioned to Feedburner for my RSS feeds. There is no need to adjust your TV set folks, everything went smoothly, according to plan. Assuming you use Textpattern, you might want to know how I did this. I will explain, and also share with you a few tricks to help you when initially configuring Feedburner. I must credit Josh Dura and Lisa McMillan for initially writing about their own experiences using TXP with Feedburner.

The “Who Cares?” Factor

First off, why would you want to process your RSS through Feedburner when it works perfectly well stemming from your own site? Is that not just adding another step of removal from your site, adding delay and further confusion? Good question, that’s one I asked myself for quite some time. Here are a few of the benefits of “burning” your feed with Feedburner:

  • More User Friendly
  • Tracking Your Stats
  • Multiple Feed Versions

Now, rather than seeing funky XML syntax when clicking on an RSS feed link, users will be taken to a page where they can read your aggregated news in an easily understandable fashion. This page also gives the user a brief crash course in what RSS actually is, and provides them with suggestions of possible RSS readers to use.

Feedburner also allows for stat tracking, and outputting of the cheezy little buttons you see on so many people’s sites, proudly displaying their number of subscribers. Besides that, there is an administrative interface showing a graphical breakdown of how many readers use each service. Prior to using Feedburner, I had no idea so many types of RSS services existed!

Yet another benefit of Feedburner is the ability to change your site’s feed into the type that your end-user prefers. For instance, Textpattern outputs RSS version 0.92, but some readers are picky and want to read RSS 2.0. With Feedburner, that’s no problem. It takes what your site outputs by default, and adds in the necessary tweaks on the fly to accomodate your picky readers.

Getting Started

First thing to do is go over to Feedburner and have them “burn” your feed. This is actually a good thing, don’t worry. When specifying an address, put in http://example.com/?atom=1&, with your own domain of course. Take note of that trailing ampersand &, because it’s important.

The reason being, we’re going to redirect your old /?atom=1 address, so we don’t want to have Feedburner pull from there, because it will create an infinite loop, continually redirecting back to itself. The ampersand is the seperator between areas of your Atom feed, so ending it with that symbol, and then not specifying anywhere makes it your default, site-wide feed.

The Code

If you’ve poked around in Textpattern’s default .htaccess file, the following lines of code probably look familiar to you:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
</IfModule>

This code handles creating clean URL schemes as the article you’re reading now. If you’re on my site now, you will notice that the in your address bar, you see the address /journal/feedburner-and-textpattern rather than /?id=173. This makes it easy to remember article addresses, as well as keeps your site search-engine friendly.

We want to continue to utilize this schema, and so we will add some of our own code between the <Ifmodule> tags. Just before the closing tag add these lines of code, yourfeed being replaced by your actual feed name of course:

RewriteCond %{QUERY_STRING} ^rss=1$
RewriteRule ^(.*)$ http://feeds.feedburner.com/yourfeed
RewriteCond %{QUERY_STRING} ^atom=1$
RewriteRule ^(.*)$ http://feeds.feedburner.com/yourfeed [R,L]

After the closing </Ifmodule> tag, you will want to add these three lines:

Redirect /rss http://feeds.feedburner.com/sonspring
Redirect /atom http://feeds.feedburner.com/sonspring
Options -Indexes

The first two lines make sure the clean URL feeds are also redirected, if you’re using /rss for example. The last line make it so that people cannot browse to your /images/ directory, among other things. It will go to a directory only if an index page exists, otherwise it will go to Textpattern’s 404 error page. This is a good idea if you don’t want people ripping off your site as easily.

Now we put all that code together, and it should look something like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
RewriteCond %{QUERY_STRING} ^rss=1$
RewriteRule ^(.*)$ http://feeds.feedburner.com/yourfeed
RewriteCond %{QUERY_STRING} ^atom=1$
RewriteRule ^(.*)$ http://feeds.feedburner.com/yourfeed [R,L]
</IfModule>
Redirect /rss http://feeds.feedburner.com/yourfeed
Redirect /atom http://feeds.feedburner.com/yourfeed
Options -Indexes

That’s it, you’re done! Now you can just sit back and relax, knowing that you’ve just made your RSS feed a whole lot more accessible and user friendly. You’ve also become an evangelist, because your feed no longer looks like gibberish, but instead educates the masses about RSS. Also, you’ve gained a way to check exactly how many people are subscribed to your site.

Latest Entries

Me, Elsewhere

icons by Komodo Media


JS Tutorial, JavaScript Tutorial, JavaScript Guide, Learn JavaScript JS, How To Learn JS, Learning JavaScript
Promote JavaScript


Disclaimer

The thoughts and opinions expressed here are mine alone, and are not necessarily shared by any other living person.