Enabling Pretty Permalinks for WordPress on a Windows Server

Category: WordPress Tags:
June 15, 2016

Although WordPress is generally associated with LAMP stacks (Linux – Apache – MySQL – PHP) you can run it on a Windows Server too. My company develops .NET applications and we have a number of Windows Servers so it makes sense to use them to run WordPress. MySQL runs well under Windows, and you also get good built-in support for PHP. But we’ll still use IIS so we have a WIMP stack (Windows – IIS – MySQL – PHP).

Specifically, I’m using a Windows Server 2008 R2 with IIS 7.5. Earlier versions may be different to set up.

When you first install WordPress the URL pointing to the posts are crude, like when I set up WP on  coinparade.co.uk:


The link works OK but I would rather the URL be:


It looks better, gives a description of what it may be about and is easier to read and remember. You also improve SEO as it gives search engines more description of the target content.

This is easy to set up with WordPress, but you need to tell your server that you are going to rewrite the URL. URL rewriting is a bit of a smoke and mirrors trick; we’re not making large internal changes, just making the URL look better for the user. And you don’t have to do much at all to achieve this. There are two stages:

In WordPress Admin, set the Permalinks to Post name.


By doing this we will use the post or page title (by default) as part of the URL. WordPress should ensure that the name is OK to use over the Internet so you don’t have to worry about bad characters in the name.

Set up the URL rewriting

This is where Windows is different from Linux machines. On Linux you would add a .htaccess file, but Windows server doesn’t use that. Windows uses web.config, a file that is very familiar to ASP.NET programmers. The web.config is just a text file that IIS uses to configure your website so it can understand the requirements of your application.

In the root of the folder where your WordPress application is, you need to add a blank text file and rename it to web.config. Note that you may already have a web.config as if you have used the IIS manager to create the site it may have already created one. Edit whichever you have and make it look like this:

<?xml version="1.0" encoding="UTF-8"?>
    <directoryBrowse enabled="false" />
      <clear />
      <rule name="WP Permalinks" stopProcessing="true">
        <match url="." ignoreCase="false" />
          <add input="{REQUEST_FILENAME}" matchType="IsFile" 
                ignoreCase="false" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" 
                ignoreCase="false" negate="true" />
        <action type="Rewrite" url="index.php" 
                appendQueryString="true" />
    <clear />
    <add value="index.php" />
    <add value="Default.htm" />
    <add value="index.htm" />
    <add value="index.html" />


This web.config is actually doing several things, but you can see the rule section clearly. URL case is set to insensitive. The files sections is just the order in which the default document is run (you probably only need index.php).

This is how I’ve done it on my development machine, but on production machines please take advice from your IT department, especially regarding security matters.