HOW TO: configure IIRF on IIS6 for Drupal and WordPress – Clean URLS

Clean URLSThis is a complete walk-through to get Ionic Shades IIRF clean and friendly URL rewriter up and running in just a few minutes. This is specifically written for Windows 2003 Server/IIS 6 and it has a complete and working example of the code you need to use for your IsapiRewrite4.ini file. If you just need the IsapiRewrite4.ini code you can skip to the end and just copy and paste, but this post might make a useful check list.

This configuration will allow you to host multiple websites on IIS6, whether the solution is for Drupal or WordPress – I’m hosting several sites on a Windows 2003 server and IIRF is works and completely free!
  1. Create a directory on your server – SERVERc$Inetpubwwwroot and arbitrarily name it ‘ISAPI
  2. Right click on the newly created ISAPI folder and select Properties > Security tab > Add
    1. Now click on the Advanced button
    2. You’ll now see the Advanced dialogue box. Select Object Types
    3. Click the box that says Computers
    4. And then click OK
    5. Next click on the Find Now button, scroll down the list until you find IIS_WPG and IUSR_YourComputerName
    6. Now click OK. and then OK again to add those names you have just selected
    7. And now select the user Internet Guest Account – IUSR_YourComputerName and give it the following permissions: Modify, Read & Execute, List Folder Contents, Read, Write
    8. Click OK
If you want to use IIRF with multiple websites, just create a folder inside your ISAPI folder and call it yourdomainname and place the files IsapiRewrite4.dll and IsapiRewrite4.ini in there. Once you’ve created the new directory, open the IsapiRewrite4.ini file and paste the following code in there:
RewriteCond %{HTTP_HOST} ^(*$ [I]
RedirectRule ^/(.*)$$1 [I,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(?!favicon.ico$)([^?]*)(?:?(.*))?$ /index.php?q=$1&$2 [L]

RewriteCond %{HTTP_HOST} ^(*$ [I]
RedirectRule ^/(.*)$$1 [I,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /index.php/$1 [L]

Just make sure you have your IsapiRewrite4.dll and IsapiRewrite4.ini in the same folder. You won’t have any trouble at all; this code will work. If there’s any chance you have a problem, re-boot your server.
Now onto configuring IIS
  1. Open your Internet Information Services (IIS) console.
  2. Open your websites folder and select website
  3. Right click on your website and select Properties
  4. Now go to the ISAPI Filters tab and click the Add button.
  5. Under Filter name: put some text in (this text is arbitrary, but it’s useful to put something appropriate in such as Ionic Shade’s IIRF).
  6. Then click on the Browse button and locate the file IsapiRewrite4.dll which is in your newly created ISAPI folder and click OK.
That’s it! You’re all setup for Clean URLs!
Topics: Web
Tags: , ,