WordPress 2.8 Pretty URLs and IIS6
For my first blog post, I thought it would be a good idea to write about the experience and process of setting up WordPress 2.8 on my Windows Server 2003 box with IIS6. I wanted to enable pretty links (you know, without the ugly index.php prefix), but IIS6 does not support this sort of behavior out of the box.
Yes, I know – WordPress and PHP belong on Linux but I prefer to think of myself as a Windows developer (C#, ASP.NET), though I work full time developing with PHP, Java\JSP, and JavaScript.
Installing WordPress is pretty straight forward, so I wont bother getting into the easy stuff. It is just a matter of extracting the files and creating a new web site in the IIS Manager with script execution permissions. I am going to assume that you already have IIS and PHP running. If you do not, read up on it at the IIS6 FastCGI forums on IIS.net. You’ll find that Windows handles PHP and WordPress just fine, but you’ll be missing one major Linux\Apache feature – mod_rewrite.
mod_rewrite is the module that allows you to create those fancy “pretty URLs” that everyone loves so much (yes, I love them too). IIS6 does not support this out of the box so we will need to install an ISAPI filter to accomplish this for us. My favorite is the open-source Codeplex project IIRF. I’ve used it in a number of projects and it always works out well for me.
For the remainder of this post I am going to assume that you already have a working WordPress installation. On to the fun part…
Installing IIRF in IIS6
Download the latest build of IIRF from Codeplex and extract it to somewhere on your hard drive. I usually have the following structure:
C:\inetpub\wwwroot\sitename.com C:\inetpub\wwwroot\sitename.com\www C:\inetpub\wwwroot\sitename.com\iirf
I do this to separate the web content from the ISAPI filter. When you extract the archive, you’ll find there are a ton of files in there. Most of them are for testing your rules but you only need the following two files:
IsapiRewrite4.dll IsapiRewrite4.ini
The DLL is the actual ISAPI filter and is the equivalent of mod_rewrite on Apache and the INI file is the configuration file which is the equivalent of an .htaccess file on Apache.
Once you have the files extracted in the correct location you must enable the filter in IIS6. Start by opening up the IIS Manager. (I’ll assume you already know how to do this.) On the left side, click on the [+] sign to expand the list. You should see Application Pools, Web Sites, and Web Service Extensions.
Enabling the ISAPI filter is a two step process. The first step is to add it as a Web Service Extension so click on that list item on the left. The list of installed ISAPI filters will be shown on the right side. Click on “Add a new Web service extension” and you’ll see the screen below:

You may enter any name, but I would recommend that you enter something that identifies this filter so that you can easily remember what it is for. A good idea is something like “IIRF for MySite.com” Once you have chosen a name, you must add the required files. Click on Add and then click on Browse. Navigate to the folder that you extracted the IsapiRewrite4.dll file and select it. Press OK. You should now be looking at the “New Web Service Extension” window again, with one file listed in the “Required files” list. Check “Set extension status to Allowed” and press OK.
The ISAPI filter is now allowed to run on this web server. For the second step, you’ll need to tell IIS which sites will actually execute this filter. Expand the “Web Sites” list by pressing the [+] button on the left. Right click on the web site that you want to enable IIRF for and click Properties. Select the “ISAPI Filters” tab and click Add. For filter name you may enter anything you want. I usually choose “IIRF” but you can enter whatever you want. Next click on Browse and once again navigate to the same IsapiRewrite4.dll file that you just selected in Step 1. Press OK to return to the web site properties window. You should now see the filter listed in the filters list. Assuming it all went according to plan, press OK again to return to the IIS Manager.
You may need to restart IIS at this point so the server loads the new ISAPI filters.
Setting up IIRF rewrite rules
This is the easy part. IIRF supports many (but not all) of the same rewrite directives that mod_rewrite does. It is worth noting that mod_rewrite is incredibly powerful and you can usually find rules for doing all sorts of cool things but they might not always work with IIRF due to lack of support with some mod_rewrite directives. IIRF is still under development so the future may hold some good news, but your mileage may vary.
IsapiRewrite4.ini must reside in the same folder as IsapiRewrite4.dll. If it does not exist, create the file now. To enable pretty URLs for WordPress all we need to do is copy the contents of a valid .htaccess file from a typical Linux\Apache WordPress installation, which I have pasted here:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Save IsapiRewrite4.ini and then head over to your WordPress Administration panel.
Enabling Pretty URLs in WordPress
Log in to your WordPress Administration Panel and click on Settings and then on Permalinks. Click on “Custom Structure” and enter the following:
/%postname%/
Now press Save. At this point, you should be ready to go. Head over to your blog and refresh it. Click on some articles and look at the URL. You should now have pretty, clean URLs.
|
|
|
|
|
![]() |













August 30th, 2009 at 12:40 am
[...] In: WordPress plugins 30 Aug 2009 Go to Source [...]
August 30th, 2009 at 5:19 am
[...] See original here: WordPress 2.8 Pretty URLs and IIS6 | Deserialized [...]
September 2nd, 2009 at 3:57 pm
Did everthing you said and all the links on my blog go to home page. Any ideas?
September 10th, 2009 at 1:51 pm
@John
Sorry, I just noticed you had left a comment. Have you had any luck getting this working? I’d be more than happy to help you out if you want.
September 15th, 2009 at 5:23 pm
I’m having the same issue as JOhn. Any solution?
September 20th, 2009 at 6:47 am
Hi Bryan
Thank you firstly for the first concise step by step explanation of what to do on an IIS6 server!! I have been searching for days.
Now, secondly, have you figured out how to deal with all the links pointing back to the home page? Would help if you could add that in asap so I can set this all up. Think I may be going permalink crazy!
I’m assuming if my blog is a subfolder of my site it becomes Rewrite Base /blog/
Thanks for this useful post
September 20th, 2009 at 8:44 am
Have attempted to do this now but my entire blog is now 404 errors. Any idea why that may happen?
I can’t see how my host has installed Isapi, but they have checked and said they have installed it correctly.
Any advice?
November 10th, 2009 at 2:08 am
I have tryed your workaround but have the same problem with the site links all going to the home page. have you any fixes for this issue.
Thanks in advance.
December 24th, 2009 at 11:27 pm
[...] Deserialized has the specifics on how to get FastCGI and mod_rewrite working before you proceed with… [...]
April 7th, 2010 at 3:27 am
Hey, I am checking this site from my BB and it looks kinda funky. Thought you’d want to know.
May 12th, 2010 at 12:51 pm
[...] Deserialized has the specifics on how to get FastCGI and mod_rewrite working before you proceed with… [...]
May 20th, 2010 at 7:24 am
Hi Bryan
I am facing this problem, I hope you can help me solving it.
My blog is http://www.promotional-buzz.com. I used the custom permalink structure to have seo friendly url’s for my blog (/index.php/%category%/%postname%), the problem is that my category links are not working at all, it goes to a blank page, also the ‘previous entries’ link at the bottom is not working. Other all my blog post links are working fine.
I am not a developer or an expert in coding languages.
can you please help me solving this issue, I’ll be extremely thankful to you!
you can also email me at promotionalbuzz@gmail.com