WordPress Pretty Permalinks on IIS 7.0

W

Microsoft Web Platform Just a quick tip if you run your WordPress site on IIS 7.0 and run into issues with pretty permalinks.

It’s pretty easy to configure: there’s a full tutorial here on the Learn IIS site and the WordPress Codex has a good overview too.

You just need to add a few lines into your web.config file.

[If you don’t know what a web.config file is don’t get too concerned. All you need to do is copy the following text into a text file, save it as web.config and put it in the WordPress directory.]

Here’s the full content of your web.config file:

<?xml version="1.0"?> 

<configuration> 

    <system.webServer> 
        <rewrite> 
            <rules> 
                <rule name="Main Rule" stopProcessing="true"> 
                    <match url=".*" /> 
                    <conditions logicalGrouping="MatchAll"> 
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
                    </conditions> 
                    <action type="Rewrite" url="index.php" /> 
                </rule> 
            </rules> 
        </rewrite> 
     </system.webServer> 
</configuration>

If you’ve already got an existing web.config then chances are you know what you are doing, and will know how to add the snippet above into your existing file.

This is also handy if you keep backups of your WordPress sites on your local machine. For example, even though my blog is hosted on Apache, I keep a full backup of it locally on my Windows 7 machine running under IIS7 (using the most excellent Web Platform Installer). Just about everything works perfectly out of the box, except the pretty URLs, so I use the rewrite lines above to make it work. The web.config file gets placed in a directory such as:

C:\inetpub\wwwroot\<your wordpress directory>\

And if you haven’t yet checked out the Web Platform Installer, then I strongly recommend it. You can get it here:

Microsoft Web Platform Installer

4 comments

By Craig Bailey

Archives