IIRF Drupal, WordPress and IIS6 – How to get them working first time – Guaranteed!

smileIf you’ve just downloaded IIRF – Ionic Shades friendly URL rewriter, but you can’t quite get get it running here’s a really easy to follow walkthrough to get your site up and running. There’s also a solution for WordPress to.

(Yes, I trawled the Internet to and none of the code I could find worked – This code will, first time Guaranteed!)

This is a complete walk-through/tutorial to get Ionic Shades IIRF clean and friendly URL rewriter up and running in just a few minutes (in fact the URL’s are so friendly I think they’re starting to interbreed – but that’s another story).

This post is specifically written for Windows 2003 Server 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 n’ paste, but this post might make a useful check list.

I know I’m not talking to idiots, but after the number of websites I’ve visited that provide dis-information / wrong information / code that simply doesn’t work. I thought I’d cover absolutely every angle – leaving no stone unturned, so that this post can become a sensible benchmark for people wanting to get IIRF easily up and running. Once you’ve done this a few times you’ll be able to get a new IIS website up and running with IIRF in about 20 seconds – literally!

This tutorial will allow you to host multiple websites on IIS6, whether they be Drupal (any version) or WordPress (any version) or both. I’m hosting over 40 sites on my Windows 2003 server and IIRF is rock solid, completely free and had I been suckered into useing ISAPI_Rewrite3 it would of cost $3,960! (£2374)

Create a directory on your system and arbitrarily name it ‘ISAPI‘. Don’t place it within your websites folder, but either one directory lower, or on another partition.

Right click on the newly created ISAPI folder and select Properties > Security tab > Add.

Now click on the Advanced button. Like so…

IIRF-folder-properties

You’ll now see the Advanced dialogue box. Select Object Types

IIRF-properties2

And just tick the box that says Computers

IIRF-properties3

And then click OK.

Next click on the Find Now button, scroll down the list until you find IIS_WPG and IUSR_YourComputerName

IIRF-properties4

(Use CTRL to make multiple selections – I did say earlier that I know you’re not stupid, but this tutorial is not just for Drupal developers, it’s also for WordPress users – LOL! Remember this website is WordPress and it’s helping you out right now so R.E.S.P.E.C.T)

Now click OK. and then OK again to add those names you have just selected

You’re now back at the Security tab, select the computer user IIS_WPG and give it the following permissions – no more, no less, it’s a security thing… Read & Execute, List Folder Contents, Read.

IIRF-properties1

And now select the user Internet Guest Account – IUSR_YourComputerName and give it the following permissions:

Modify, Read & Execute, List Folder Contents, Read, Write.

IIRF-properties5

Oy, this tut is taking me forever. I do hope you leave me a comment when your site is up and running.
(or maybe click on a Google Ad banner – Eeek! I didn’t just say that…)

Now click OK.

Right, that’s your folder permissions all done. 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.

Drupal (all versions) IsapiRewrite4.ini code. Yes this code really does work. It’s running right now on Windows 2003 server for my Astrophysics website http://www.manonmars.co.uk in fact if you click on the link you’ll see the URL get re-written to http://manonmars.co.uk

Drupal

(all versions)

RewriteCond %{HTTP_HOST} ^(www\.manonmars\.co\.uk).*$ [I]
RedirectRule ^/(.*)$ http://manonmars.co.uk/$1 [I,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(?!favicon.ico$)([^?]*)(?:\?(.*))?$ /index.php?q=$1&$2 [L]

If you have a dot com, then it’s a simple modification to this:

RewriteCond %{HTTP_HOST} ^(www\.yourdomainname\.com).*$ [I]
RedirectRule ^/(.*)$ http://yourdomainname.com/$1 [I,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(?!favicon.ico$)([^?]*)(?:\?(.*))?$ /index.php?q=$1&$2 [L]

WordPress

(all versions)

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

Again, if you have a dot com, it’s a simple modification to this:

RewriteCond %{HTTP_HOST} ^(yourdomainname\.com).*$ [I]
RedirectRule ^/(.*)$ http://www.yourdomainname.com/$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 first time. If there’s any chance you have a problem,  re-boot your server. There is probably another way of doing this without re-booting, but I don’t know what it is.

And now last, but by no means least:

IIS

Just run your Internet Information Services (IIS) Manager. Open your websites folder and select the website that you’d like clean / friendly URL working on.

Right click on your website and select Properties.

IIRF-properties6

Now go to the ISAPI Filters tab and click the Add button.

IIRF-properties7

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). Then click on the Browse button and locate the file IsapiRewrite4.dll which is in your ISAPI folder.

IIRF-properties8

And then click OK.

You know what? You’re done. That’s it, all finished. Will it work? YES IT WILL. Will you have any problems? NO YOU WON’T. If for any reason you don’t have immediate success, the only thing you will need to do is to re-boot your server.

I would like to thank the man who is so cool, even his own Mother knows him only as Ionic Shade… for writing IIRF, it’s absolutely great, it’s powerfull and it’s completely free. Though I’m sure he would appreciate a small donation – as might I (hint, hint). But if you’re poor and can’t afford it, no problem whatsoever. I’m glad to of helped!

Happy Web Designing!

Simon.

Related posts:

  1. IIRF WordPress – URL Rewriting for IIS6.0
  2. Google AJAX Translation not working with WordPress & Artisteer
  3. IIS and Drupal – Enable Clean URL’s
  4. IIS6 Compression for PHP – How to Compress CSS with GZip Tutorial
  5. Drupal – The selected file… could not be uploaded. Only JPEG, PNG and GIF images are allowed
  6. Access denied – Drupal 6.x
  7. How to check if Google Analytics is working correctly.


13 Comments

  1. Comments  IIS and Drupal – Enable Clean URL’s   |  Friday, 13 November 2009 at 12:39 pm

    [...] http://www.caspianit.co.uk/iirf-drupal-and-iis6/ [...]

  2. Comments  imagecache wrong path - SOLVED!   |  Tuesday, 17 November 2009 at 2:35 pm

    [...] Just for completeness, I have written a complete tutorial / walk through for installing IIRF on Windows 2003 Server. There’s everything you could need there from start to finish, it’ll only take you a few minutes to go through – it’s a recommended read! http://www.caspianit.co.uk/iirf-drupal-and-iis6/ [...]

  3. Comments  carl   |  Thursday, 25 February 2010 at 2:33 pm

    Hello,
    I cannot seem to get this working. I have followed your tutorial step-by-step, but am not getting the expected results. Is there somehow I can start to troubleshoot – logs I can look in or anything like that. I see no indication that any piece of it is working.

    Thanks

  4. Comments  Simon Nicol   |  Thursday, 25 February 2010 at 3:38 pm

    Have you re-started your server? That’s the only thing that you might need to do. If you’ve followed along every step is complete.

  5. Comments  holmes   |  Saturday, 17 April 2010 at 1:00 am

    Simon, I hate to bug you with this one, but you’re talking here about WordPress, Drupal, and IIS6, and that’s what I’m working with, so here goes:

    Switching a site over to Drupal (example.com). Importing current WordPress blog (example.com/blog) into Drupal as well. So far, no problems.

    Now I want to make sure that existing links will continue to work, so I need to go from:
    example.com/blog/index.php/04/2009/blog-entry-title
    to
    example.com/blog/04/2009/blog-entry-title

    Am I on the right path with IIRF? (Already using it for clean urls in Drupal)

    Any help is hugely appreciated!

  6. Comments  Simon Nicol   |  Saturday, 17 April 2010 at 8:50 am

    @Holmes,

    Yes you are indeed. One thing to keep in mind is WordPress’ excellent SEO – in my opinion the best of the bunch is META SEO so it’s worth taking the time to copy over the META and Keyword info to maintain your search placement, also remember that when googlebot finds your new site you’ll invariably find that your site does ‘the Google bounce’ so you’ll disapear down the rankings, if not completely from the search engine until you get re-listed. This is nothing to worry about, but the process could take around a month to get back the rankings that you had.

    Your URL re-writing is the way to go. Make sure that each re-write is marked as a ‘permanent redirect’. To re-wite your URL’s effectively it would be best to study REGEX. Regular expression matching can seem a bit daunting to start with, but there’s an excellent tutorial here http://www.regular-expressions.info/ you only need to remove the /index.php bit so it’s pretty straight forward.

    All the best.

    Simon.

    P.S.

    As an added thought because you’re using IIS6 I’ve written a post on optimising IIS6′s delivery of pages. (Google now take page optimisation as yet another criteria for search placement – so it’s well worth doing.) It just takes a few ‘tweaks’ to your server and you can get your pages being delivered at DOUBLE the speed – well worth taking a look. I have a post about how to do that here http://www.caspianit.co.uk/iis6-website-optimisation-for-webpagetest-org/.

  7. Comments  Ray   |  Wednesday, 17 November 2010 at 9:36 pm

    Simon, I have followed ur instructions to the letter and I have restarted my server but when I go look at the ISAPI filter it is not showing the green arrow. I have gone to drupal to engage the clean urls with no luck…any ideas? I’ve been working on this for 2 days now….Thanks for your time and efforts!

  8. Comments  Simon Nicol   |  Thursday, 18 November 2010 at 6:12 pm

    Goodness, that’s a new one. I can’t think what to suggest, I’ve written some other posts about this elsewhere on this site. The only other person to take it to would be IonicShade himself, cos it just doesn’t make sense.

    See what else is on this site or have a look at Ionic’s homepage, maybe he could help if you emailed him.

    All the best
    Simon

  9. Comments  Ray   |  Thursday, 18 November 2010 at 6:14 pm

    I FINALLY got it to work!!!! I had to add an iirf.ini file to the folder that contained the drupal files and a bit of code I snactched up form the internet and it worked….

  10. Comments  Simon Nicol   |  Thursday, 18 November 2010 at 6:16 pm

    @Ray
    Congrats!!

  11. Comments  Ray   |  Thursday, 18 November 2010 at 6:25 pm

    thanks now on to magento!

  12. Comments  mike   |  Monday, 14 March 2011 at 10:10 pm

    Hello,
    I’m following your tutorial on win 2k3, only I don’t have the “computers” box to select in object types

    please help

  13. Comments  trung   |  Monday, 11 July 2011 at 9:20 pm

    Just quick question, which version of IIRF are you using in this tutorial?

Leave a Reply