Huddled Masses
The internet home of Joel "Jaykul" Bennett...
Browse: Home / WordPress 2.3 Transition

WordPress 2.3 Transition

By Joel 'Jaykul' Bennett on 26-Sep-2007

So, I noticed WordPress 2.3 was out, and upgraded with no issues. Of course, then I switched all my categories into tags, and changed my permalinks to leave out my nickname (something I couldn’t do with the old WordPress I was running) and things started going missing.

Using some .htaccess rules I was able to redirect my category index pages to the new tag pages fairly successfully, so that people’s bookmarks and feedreaders (don’t forget people can subscribe to feeds for all of these weird index pages) in what I hope is a clean way:


# Keep this out of the wordpress section, or it will get overwritten
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# rewrite categories as tags
RewriteRule ^category/(.+)$ tag/$1 [redirect=permanent,last]
# rewrite posts by my nick to my new /%postname%/ permalinks
RewriteRule ^jaykul/(.+)$ $1 [redirect=permanent,last]
# rewrite up to four levels of nested categories as tag intersections
# But don't forget to allow access to the feeds
RewriteRule ^tag/([^/+,]+)/(?!feed|rss|rss2|atom)([^/+,]+)/?$ tag/$1+$2/              [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/(feed|rss|rss2|atom)/?$ tag/$1+$2/$3              [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/?$ tag/$1+$2+$3/                         [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/(feed|rss|rss2|atom)/?$ tag/$1+$2+$3/$4  [redirect=permanent,last]
RewriteRule ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/([^/]*)/?$ tag/$1+$2+$3+$4/              [redirect=permanent,last]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
 

Some interesting things to note:

  • You have to redirect your categories to the tags page so that user agents (browsers and RSS readers) can update their links (if they bother, sigh).
  • You have to take special care of the fact that people can reach the rss feeds as categoryname/feed/ or categoryname/feed/rss/ or categoryname/rss/ ...
  • You need to be careful with the redirects because you can cause infinite loops.
  • You can link to tags and their feeds as UNIONS or as INTERSECTIONS, but not both.

Did you know that people can navigate to pages for multiple tags? In fact, /tags/powershell+development/ will link to items tagged with both powershell and development, whereas /tags/powershell,scripting/atom is the Atom feed for items tagged with either PowerShell or Scripting (or both). I wrote my rules to target the intersection, since that’s sort-of how categories worked so it most nearly preserves my previously working feeds.

I also picked a random new theme, as you can see — I’ve been working on it for a couple of evenings, and there’s still more work to do. So far I’ve widget-enabled it, and partially tag-enabled it … I’m going through the process of modifying a couple of my plugins into widgets (how did I miss this so completely in the past?), and then I’ll hide that extra sidebar on the post pages, and make it variable width.

I suppose I need to modify the header too, it’s hard to read, and if anyone has any ideas about a better way to present code … I’m open to suggestions. Of course… I also need to make it all validate XHTML 1.1 Strict (‘cause I’m like that).

Similar Posts:

    None Found

Posted in Huddled | Tagged htaccess, mod_rewrite, WordPress

« Previous Next »

Lijit Search

Tags

.Net .Net 2008 Scripting Games Automation Bugs Design Development Funny Gadgets GeoShell GUI Huddled Masses Internet licensing Microsoft Modules My Software News Personal PInvoke Pipeline Politics PoshCode PoshConsole PowerBoots PowerShell PowerShell Functions PowerTips Rants Recommender Repository Scripting ShowUI Software Solutions Textile Tips User Group UserInterface WalkThrough WebHosting Windows 7 WordPress WPF Xml

About Huddled Masses

This is web site is dedicated to the musings of Joel Bennett (aka Jaykul) about technology, software, software development, the web, and the world.

Any resemblance of the views expressed and the views of my employer, my terminal, or the view out my window are purely coincidental. The resemblance between them and my own views is non-deterministic. The question of the existence of views in the absence of anyone to hold them is left as an exercise for the reader.

P.S.: I occasionally link to things I think are great. When I do, I occasionally find a "referral code" so I can make a little cash. I promise that I don't link to anything just because of that cash (I wouldn't cross the street for the amount of cash those links bring in, never mind write a whole blog post) ... but I do not promise that things I link to will stay great as time passes, nor that you will agree with me about their greatness!

Archives

  • January 2012
  • October 2011
  • August 2011
  • July 2011
  • June 2011
  • March 2011
  • February 2011
  • January 2011
  • November 2010
  • August 2010

Copyright © 2012 Joel Bennett.

Powered by WordPress and Hybrid.