
This is completely outdated now: needs update
Take a look up in the address bar. No more unsightly /index.php/2008/12/15/post-name up there anymore. Just sweet, sweet /%category%/%postname%/.
Super easy if I were smart and ran Apache instead of IIS. Maybe one day I’ll get around to moving my home server from windows to some flavor of linux. Who am I kidding, I’ve got a family, a job and mortgage … no way I’ll ever bother.
So, I’ve known about isapi rewrite filters for a long time but just kind of never bothered. And back when I first looked, the only big option was Helicon’s asapi rewrite which, unfortunately, the free lite version has too many limitations for what I wanted to do (not run rewrites on all of my websites). But this time around, when I just looked on a whim, I get Ionic’s IIRF which is free and runs on individual sites.
To setup I used this guy’s tutorial because it was the easiest to read. Not that there’s anything hard here, I just like really really easy when the kid is running around and the wife is asking me about Christmas decorations. In case the link goes away here’s the short version:
Now, for the ini file. I copied this guy’s rewrite rules because he went that extra mile and thought about old links that might be out there. In the interest of full transparency, I haven’t looked at any of the documenation to understand the formatting of the rewrite rules and I’ve just copied the work of others. I don’t how to fix the rules to quit throwing errors in the log file, but they appear to work just fine. If I get a few minutes I might sit down and see what other cool stuff I’m missing that I could be doing. Oh, and I reserve the right to always be completely confused and only half understand what I’m talking about.
Next up is looking over htaccess rules for blocking hotlinking.
Here’s my rewrite file:
# Set logging directory and logging level
#RewriteLog
#RewriteLogLevel 3
# Redirect url with index.php to url without
# throws errors about [R] but still works
RewriteRule ^/index.php(.*)$ /$1 [I,R=301]
# Rewrite for old url with date
# throws errors about [R] but still works
RewriteRule ^/(index.php/)*([1-2][0-9]{3})/([0-1][0-9])/([0-3][0-9])(.*)$ /$2/$3$5 [I,R=301]
# Normal wordpress redirect
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(?!index.php)(?!wp-)(.*)$ /index.php/$1
[update: Okay, I'll admit I'm not the smartest of the small brains, but I really should've recognized R=301 as a http status code. So now I'm curious why the guy I copied my rewrite rules from used a rewrite rule here instead of a redirect?]