<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses &#187; mod_rewrite</title>
	<atom:link href="http://huddledmasses.org/tag/mod_rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Fri, 27 Apr 2012 05:42:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>WordPress 2.3 Transition</title>
		<link>http://huddledmasses.org/wordpress-23-transition/</link>
		<comments>http://huddledmasses.org/wordpress-23-transition/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 20:28:28 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://HuddledMasses.org/jaykul/wordpress-23-transition/</guid>
		<description><![CDATA[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_).]]></description>
			<content:encoded><![CDATA[	<p>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&#8217;t do with the old WordPress I was running) and things started going missing.</p>

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

	<div class="apache code apache" style="font-family:monospace;"><br />
<span style="color: #adadad; font-style: italic;"># Keep this out of the wordpress section, or it will get overwritten</span><br />
&lt;<span style="color: #000000; font-weight:bold;">IfModule</span> mod_rewrite.c&gt;<br />
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span><br />
<span style="color: #00007f;">RewriteBase</span> /<br />
<span style="color: #adadad; font-style: italic;"># rewrite categories as tags</span><br />
<span style="color: #00007f;">RewriteRule</span> ^category/(.+)$ tag/$<span style="color: #ff0000;">1</span> [<span style="color: #00007f;">redirect</span>=permanent,last]<br />
<span style="color: #adadad; font-style: italic;"># rewrite posts by my nick to my new /%postname%/ permalinks</span><br />
<span style="color: #00007f;">RewriteRule</span> ^jaykul/(.+)$ $<span style="color: #ff0000;">1</span> [<span style="color: #00007f;">redirect</span>=permanent,last]<br />
<span style="color: #adadad; font-style: italic;"># rewrite up to four levels of nested categories as tag intersections</span><br />
<span style="color: #adadad; font-style: italic;"># But don't forget to allow access to the feeds</span><br />
<span style="color: #00007f;">RewriteRule</span> ^tag/([^/+,]+)/(?!feed|rss|rss2|atom)([^/+,]+)/?$ tag/$<span style="color: #ff0000;">1</span>+$<span style="color: #ff0000;">2</span>/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[<span style="color: #00007f;">redirect</span>=permanent,last]<br />
<span style="color: #00007f;">RewriteRule</span> ^tag/([^/+,]+)/([^/+]+)/(feed|rss|rss2|atom)/?$ tag/$<span style="color: #ff0000;">1</span>+$<span style="color: #ff0000;">2</span>/$<span style="color: #ff0000;">3</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[<span style="color: #00007f;">redirect</span>=permanent,last]<br />
<span style="color: #00007f;">RewriteRule</span> ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/?$ tag/$<span style="color: #ff0000;">1</span>+$<span style="color: #ff0000;">2</span>+$<span style="color: #ff0000;">3</span>/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [<span style="color: #00007f;">redirect</span>=permanent,last]<br />
<span style="color: #00007f;">RewriteRule</span> ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/(feed|rss|rss2|atom)/?$ tag/$<span style="color: #ff0000;">1</span>+$<span style="color: #ff0000;">2</span>+$<span style="color: #ff0000;">3</span>/$<span style="color: #ff0000;">4</span> &nbsp;[<span style="color: #00007f;">redirect</span>=permanent,last]<br />
<span style="color: #00007f;">RewriteRule</span> ^tag/([^/+,]+)/([^/+]+)/([^/+]+)/([^/]*)/?$ tag/$<span style="color: #ff0000;">1</span>+$<span style="color: #ff0000;">2</span>+$<span style="color: #ff0000;">3</span>+$<span style="color: #ff0000;">4</span>/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[<span style="color: #00007f;">redirect</span>=permanent,last]<br />
&lt;/<span style="color: #000000; font-weight:bold;">IfModule</span>&gt;<br />
<br />
<span style="color: #adadad; font-style: italic;"># BEGIN WordPress</span><br />
&lt;<span style="color: #000000; font-weight:bold;">IfModule</span> mod_rewrite.c&gt;<br />
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span><br />
<span style="color: #00007f;">RewriteBase</span> /<br />
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-f<br />
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-d<br />
<span style="color: #00007f;">RewriteRule</span> . /index.php [L]<br />
&lt;/<span style="color: #000000; font-weight:bold;">IfModule</span>&gt;<br />
<span style="color: #adadad; font-style: italic;"># END WordPress</span><br />
&nbsp;</div>

	<p>Some interesting things to note:</p>

	<ul>
		<li>You have to <strong>redirect</strong> your categories to the tags page so that user agents (browsers and <span class="caps">RSS</span> readers) can update their links (if they bother, <em>sigh</em>). </li>
		<li>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/ ... </li>
		<li>You need to be careful with the redirects because you can cause infinite loops. </li>
	</ul>
	<ul>
		<li>You can link to tags and their feeds as <span class="caps">UNIONS</span> or as <span class="caps">INTERSECTIONS</span>, but not both.</li>
	</ul>

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

	<p>I also picked a random new theme, as you can see &#8212; I&#8217;ve been working on it for a couple of evenings, and there&#8217;s still more work to do. So far I&#8217;ve widget-enabled it, and partially tag-enabled it &#8230; I&#8217;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&#8217;ll hide that extra sidebar on the post pages, and make it variable width.</p>

	<p>I suppose I need to modify the header too, it&#8217;s hard to read, and if anyone has any ideas about a better way to present code &#8230; I&#8217;m open to suggestions.  Of course&#8230; I also need to make it all validate <span class="caps">XHTML</span> 1.1 Strict (&#8216;cause I&#8217;m like that).</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/wordpress-23-transition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

