Pretty permalinks using IIS 8/IIS 8.5

When I threw this blog together, I had chose one of the default Permalinks options of:

http://domain/index.php/%postname%

I wanted to get that index.php out of there and that is where my journey began.

I am running WordPress on IIS 8.5 and Windows Server 2012 R2. First, I just went in and attempted to edit the Permalinks under settings, but when I went to save I got the below error.

htaccess_writable

I did some more research, created my own .htaccess at the root of my WordPress site and after no more luck realized that .htaccess is only used for Apache web servers. This led me to do some research into what permalinks is actually doing and found it just sets up a URL rewrite. Basically any request for a non-existent URL redirects to, in my case, index.php.

After searching through a handful of links, I came across a page on the codex that outlined the basics of what I needed. http://codex.wordpress.org/Using_Permalinks. The problem is that the example on that page still didn’t work.

I dug back into Google and read through a few pages. I eventually realized what this web.config file is actually doing. It is just a URL rewrite rule in IIS! I logged back into my web server and opened the IIS Administration console. I manually added the URL Rewrite rule and didn’t add any mappings.

IIS_url_rewrite

 

 

 

This left me with a very similar web.config, but a working one!

Thanks to Jared in the comments for an additional tip:

For anyone that runs their wordpress site from a sub directly like http://www.domain.com/wordpress you need to do two things:

  1. Change “wordpress” to whatever your subdirectory structure is.
  2. Add the following two lines to your web.config
    1. match url=”wp/.*” /
    2. action type=”Rewrite” url=”wp/index.php” logRewrittenUrl=”true” /

Leaving you with this!

 

10 thoughts on “Pretty permalinks using IIS 8/IIS 8.5

  1. Chris

    THANK YOU!!!!! You have no idea how much time I spent trying to figure that out!!

  2. Anonimous

    Simple and functional. How the hell did not the 100 posts before this explained it like this.

    Good work. Cheers

  3. Ian

    Aw man! thanks so much. I just moved over from an Apache server and this was killing me.

  4. Anthony

    Thanks! I was pulling my hair out with this one.

  5. Rigo

    Just great, this took a bit of research from here and a bit from there, your page and some videos and I am all set–permalinks for WordPress in IIS 8.5–THANK YOU!!

  6. Jared

    Necro comment!

    As everyone else is saying this was helpful because all other articles say IIS 7 and above, which includes 8 and 8.5 of course. However those articles dont work. It wasnt until I came here that I got the fix.

    For anyone that runs their wordpress site from a sub directly like http://www.domain.com/wordpress you’ll have to modify two lines above:

    and

    Of course changing “wordpress” to whatever your subdirectory structure is.

    • Jared

      Looks like the code was removed from my previous comment so I’ll leave out the opening and closing brackets. The two lines you have to modify are:

      match url=”wp/.*” /
      and
      action type=”Rewrite” url=”wp/index.php” logRewrittenUrl=”true” /

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">