Any ideas how to enable Clean URLs on drupal when the server is IIS?


A quick google search returned this guide, Drupal Clean URL's on IIS. Is this helpful?

  • Now I only need to contact my hosting and ask what they did on the subject :) – elcuco May 27 '09 at 18:09

After a bit of pain, my great hosting admin and I have managed to get Ionic ISAPI Rewriting Filter (IIRF) RELEASE working on IIS v6.0. I thought I would post how we got it working; and hopefully our solution will help you!

I had the site working on a different type of server before I started, so I ran into some trouble with my existing Drupal configuration. So, if you also already have the site set up somewhere else, make sure you do the following before moving to the new server:

  1. Disable Clean URLs in Drupal's Admin -> Site Configuration -> Clean URLs
  2. If you have the Global Redirect module turned on, make sure you set the "Non-clean to Clean" option to "Off" at Admin -> Site Configuration -> Global Redirect

Here are the steps that we took to get it working:

  1. Downloaded Ionic ISAPI Rewriting Filter RELEASE and uncompressed the file
  2. Followed the instructions in the guide. The guide is included in the ZIP file at AdminGuide > Help > IirfGuide.chm. We used the IirfGlobal.ini file quoted at the end of this post.
  3. Restarted IIS
  4. Created an Iirf.ini file in the root folder of the site, entering only StatusUrl /iirsStatus RemoteOk. We then tested to see if IIRS was working by going to http://mysite.example.com/iirsStatus. It should print out some status lines for you.
  5. Changed the Iirf.ini file to it's final form, as quoted at the end of this post
  6. Turned on Clean URLs again. Don't turn on Global Redirect's "Non-clean to Clean" option though! It will redirect the page endlessly.


RewriteEngine ON
RewriteFilterPriority DEFAULT
NotifyLog OFF


# Do not pass to drupal if the file or directory exists
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Handle query strings on the end
RewriteRule /(.*)\?(.*)$ /index.php\?q=$1&$2 [I,L]

# now pass through to the generic handler
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /index.php?q=$1 [I,L]
  • I suddenly found that IIRF has a DrupalRules.ini file in the ExampleIniFiles folder, but it doesn't work with the update.php script. My solution above does. – mparker17 Nov 27 '09 at 21:57
  • 1
    The RewriteBase rule from Apache doesn't work in IIRF, so you would have to change some lines if your Drupal site is in a sub-folder of a domain. Specifically: RewriteRule /(.*)\?(.*)$ /index.php\?q=$1&$2 [I,L] would become RewriteRule /(.*)\?(.*)$ /subfolder/index.php\?q=$1&$2 [I,L] and RewriteRule ^/(.*)$ /index.php?q=$1 [I,L] would become RewriteRule ^/(.*)$ /subfolder/index.php?q=$1 [I,L] – mparker17 Nov 27 '09 at 22:02
  • It would seem that Global Redirect's "Non-clean to Clean" option is turned on by default. So, make sure you turn off Clean URLs before installing this module! – mparker17 Dec 1 '09 at 14:51
  • One more thing... we also discovered that you need to use Windows line endings in the configuration files; otherwise your files won't work. The files also worked fine when encoded in UTF-8 without a Byte Order Mark. – mparker17 Dec 4 '09 at 3:01

There's some documentation on Drupal's site about using clean URLs in II6 that I'm currently using. Check out http://drupal.org/node/3854.

The short answer is download ISAPI Rewrite 2 lite from http://www.isapirewrite.com/. The lite version only lets you configure one set of rewrite rules for your entire IIS configuration, but works well and is free.

The paid version lets you specifiy rewrite rules for each site you have configured in IIS, but required more configuration of IIS.

The ISAPI rules I'm using are:

# Helicon ISAPI_Rewrite configuration file
# Version

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

If your Drupal installation was installed under a subdirectory, you'd want to adjust these rules a bit.

  • Do you simply put these in .htaccess? – dorien Feb 27 '14 at 14:54

I have used Ionic Rewrite for a while now... it's free and works great



I managed to implement this by installing the URL rewriter module and creating a web.config file in the base directory with this code:

<?xml version="1.0" encoding="UTF-8"?>
      <rule name="Drupal clean URLs" enabled="true">
        <match url="^(.*)$" ignoreCase="false" />
        <conditions logicalGrouping="MatchAll">
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />    
          <add input="{REQUEST_URI}" negate="true" pattern="/favicon.ico$" />
        <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />

There's more information in this post, which goes on: "You also need to install a hotfix to correct REQUEST_URI behaviour when using PHP via the FastCGI module. See KB954946 for more information. A symptom of this problem is when all form submissions get redirected to the frontpage of the site."


IIRF is a free URL rewriter, works on IIS and works with drupal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.