Drupal clean URLs on IIS 7
Heine Thu, 2008/10/16 - 10:57
To get Clean URLs working on IIS 7, install the new URL rewriter module (x86, x64) and add the following to the system.webServer section of the sites' web.config:
<rewrite>
<rules>
<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$" />
</conditions>
<action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
<rules>
<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$" />
</conditions>
<action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
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.
Update: You may want to look into the Microsoft Web Platform, which contains an installer for Acquia Drupal.
Comments
Awesome help! However, where do I add that code to.
Submitted by Cheatah (not verified) on Fri, 2009/03/27 - 17:48Where do I add the code? Do I need to create a web.config file in the directory?
Nevermind Figured it out.
Submitted by Cheatah (not verified) on Fri, 2009/03/27 - 17:52You can just create a web.config from scratch and put the following info:
<?xml version="1.0" encoding="utf-8" ?>
Configuration tag
Submitted by Heine on Thu, 2009/05/21 - 10:14If you later try to configure your site, IIS complains loudly when there's no configuration tag. Use the following template to prevent this.
<configuration>
<system.webServer>
</system.webServer>
</configuration>
The rewrite block then goes inside the
system.webServer
section.wha.. where?
Submitted by n00b (not verified) on Thu, 2009/08/13 - 06:10for clarification...
The web.config file sits in the site's root directory?
The initial web.config file
Submitted by n00b (not verified) on Thu, 2009/08/13 - 06:13Google be my guide.
And a good guide it is
Submitted by Heine on Thu, 2009/08/13 - 14:30And a good guide it is :)
Thanks for posting back.
I don't know if that was
Submitted by ThomasR (not verified) on Thu, 2010/04/08 - 17:10I don't know if that was already the case before, but you just need to install the rewrite module and import the Drupal .htaccess file...
That did not work in 2008
Submitted by Heine on Sun, 2010/04/11 - 16:53That did not work in 2008 :)
Glad to hear it has improved.
Perfect!! =)
Submitted by Otto (not verified) on Sat, 2010/07/10 - 17:43Thank you! The tags you mentioned above worked perfectly on my Windows Server 2008 64bits Drupal installation.