Since I moved from WordPress to Dotclear, my feed URLs changed. Tonight (this morning), I mapped the old ones to the new ones. There were several complicating factors:
- WordPress uses a whole mess of different URLs for feeds.
- WordPress is very popular, so most of the posts I found were about how to point to WordPress feed URLs, not how to redirect WP URLs to another system's. I found some Feedburner docs, but they were old and not quite appropriate.
- mod_rewrite is powerful and complicated. I wanted to use the much simpler (and lower overhead) redirects provided by mod_alias.
- WordPress uses Query Strings, which are not part of the normal URL space, and thus awkward to work with.
Thanks to #apache (particularly Sling) for a pointer in the right direction.
Here's what I ended up with in the .conf file for my www.extrapepperoni.com virtual host (yes, I realize I mapped some URLs that were never used, but I cannot go check what was available now that the old site is mothballed):
# WP uses top-level years for permalinks, but DC puts them under /post/.
RedirectPermanent /2008 http://www.extrapepperoni.com/post/2008
RedirectPermanent /2007 http://www.extrapepperoni.com/post/2007
RedirectPermanent /2006 http://www.extrapepperoni.com/post/2006
# People who just ask for a feed, without specifying type. Note `$`, so these don't eat URLs that do specify type.
RedirectMatch permanent /feed$ http://www.extrapepperoni.com/feed/atom
RedirectMatch permanent /feed/$ http://www.extrapepperoni.com/feed/atom
# If they specify a type, provide DC's closest match.
RedirectPermanent /feed/atom/ http://www.extrapepperoni.com/feed/atom
RedirectPermanent /feed/rss2/ http://www.extrapepperoni.com/feed/rss2
RedirectPermanent /feed/rss/ http://www.extrapepperoni.com/feed/rss2
RedirectPermanent /feed/rdf/ http://www.extrapepperoni.com/feed/rss2
# Not sure if putting it inside this block avoids unnecessary processing for sub-paths, but it works this way, so it's all good.
# For all the feed queries, map to the appropriate feed URL, and strip the Query String to avoid looping.
# These are permanent redirects, and end mod_redirect processing.
<Location />
SetHandler dotclear
RewriteEngine On
RewriteCond %{QUERY_STRING} feed=atom
RewriteRule / http://www.extrapepperoni.com/feed/atom? [L,R=301]
RewriteCond %{QUERY_STRING} feed=rss2
RewriteRule / http://www.extrapepperoni.com/feed/rss? [L,R=301]
RewriteCond %{QUERY_STRING} feed=rss1
RewriteRule / http://www.extrapepperoni.com/feed/rss? [L,R=301]
RewriteCond %{QUERY_STRING} feed=rss1
RewriteRule / http://www.extrapepperoni.com/feed/rss? [L,R=301]
RewriteCond %{QUERY_STRING} feed=rdf
RewriteRule / http://www.extrapepperoni.com/feed/rss? [L,R=301]
RewriteCond %{QUERY_STRING} feed
RewriteRule / http://www.extrapepperoni.com/feed/atom? [L,R=301]
</Location>