• Link Title

    Short description of the page you're linking to

WordPress Permalink formatting and WIMP

First off, thanks goes to Frank Cornwell for having what I found to be the only full documentation on how to setup WordPress on WIMP (Windows-IIS-MySQL-PHP). I only present this blog to add to his work on Permalink formatting, which is item #6

—-Cornwell Excerpt—-

WordPress allows you to specify whether you want Permalinks (more accurately all the links on your site), to be specified using parameters, like this: /index.php?year=2004&monthnum=07&day=07, or using paths, like this: /feed/2004/07/07/. The latter format is preferred because search engines can be touchy about following links with lots of parameters, as it’s harder for them to determine if they’ve gotten into an infinite loop.

The Permalinks configuration page (Admin -> Options -> Permalinks), is where you specify the permalinks format. The two most common formats are /archives/%year%/%monthnum%/%day%/%hour%/%minute%/%second%/ or /archives/%year%/%monthnum%/%day%/%postname%/.

The former produces links that look like /archives/2004/07/07/12/01/01/ and the latter produces links that look like /archives/2004/07/07/weblog_entry_title_goes_here/. I chose the latter format because it gives the name of the blog right in the link.

But choosing the format was easy, the real problem is that IIS doesn’t have a built-in rewrite rule handler like Apache does. Luckily with a quick glance at Google found an ISAPI ReWriter for IIS – ISAPI_Rewrite. I installed the Lite version (free), and after a little futzing with the rewrite rules, got it working.

Here’s how I did it:

I downloaded and installed the Lite version from here.

You can configure IIS to use ISAPI_Rewrite on all sites, or you can install it on only individual sites. I chose the latter.
To install ISAPI_Rewrite on a single site, open the IIS Internet Service Manager. Right-click on the site you want to install it on, and choose “Properties” from the popup menu. Select the “ISAPI Filters” tab, then click the “Add” button. Name it “ISAPI Rewrite”, and click “Browse” to find the ISAPI_Rewrite.dll in the install location. Choose the ISAPI_Rewrite.dll, then click “Open” to choose the file. Finally, click “OK” to close your site’s properties panel.

Now you have to add some Rewrite Rules to the ISAPI_Rewrite.dll httpd.ini file. You’ll find this file in the same folder as the ISAPI_Rewrite.dll file.

A nice WordPress feature is that at the bottom of the Permalinks page they provide the Apache Rewrite Rules for the Permalinks format you’ve chosen. What they provide there is very close to what we need for ISAPI_Rewrite, but we will have to tweak it a bit.

The first three lines of the WordPress rewrite rules for my Permalinks options looked like this (notice that the last line is wrapped here):

RewriteEngine On
RewriteBase /
RewriteRule ^archives/category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?category_name=$1&feed=$2 [QSA]

I changed them to read as follows (again the last line is wrapped):

—Cut Excerpt—


RewriteRule /archives/category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php\?category_name=$1&feed=$2 [I,U,O]

What did I do?

  • I threw the first two lines away (RewriteEngine and RewriteBase)
  • Changed the ^ at the start of the first RewriteRule from a ^ to a /
  • Added a back slash (”\”) between xxx.php and the ? mark
  • Changed [QSA] to [I,U,O] at the end of the line
  • Now you can do the same to the rest of the rewrite rules.

    Lastly, look for a line that reads like such:

    RewriteRule /comments/feed/?([_0-9a-z-]+)?/?$ /wp-feed.php?feed=$1&withcomments=1 [I,U,O]

    DELETE THIS LINE. Otherwise, you will get a page not found error when anyone attempts to post a comment. That is because IIS5 does not pass permalink variables when posting comments, therefore we do not set permalinks for the comments.

    Save the file, and you’re done.

    —-Cornwell Excerpt—-

    Now, because we’re using the Lite version, we need to restart IIS (in fact you need to do this whenever you make changes to the ISAPI_Rewrite rewrite rules). So, fire up a command window, type “iisreset /restart”, hit return, wait for IIS to restart, and you’re in business – Permalinks as they’re supposed to be.

    —-Cut Excerpt—-

    You can see my rewrite rules here.

    If you liked this post, subscribe to Wpdesigner's RSS feed.

    Filed under: IIS5, ISAPI ReWrite, WordPress

    Leave a Reply