By brian, 5 months and 18 days ago

Wordpress Permalinks on IIS with ISAPI_Rewrite

I've run WordPress here on my CentOS box for nearly 4 years and am quite familiar with the software. Recently, I had a client on a Windows system request a blog be added to their web store. Their webstore is written in ASP and runs on windows. They wanted to stay on the same domain for SEO purposes, (thus site.com/blog/ instead of blog.site.com or a new .com). Without the subdomain or new IP, there's no way to change DNS for a subdirectory to a different server. This meant I had to get it working on IIS.

Native installations for apache tend not to port well (or perhaps, easily) over to windows/IIS. Thankfully, ISAPI3 from HeliconTech.com supports .htaccess files and makes the job a little easier. Wordpress works fine on windows/IIS until you want nice permalinks.

After MUCH searching, testing, and error log analysis, I've got a working solution for Windows Server 2003 with ISAPI_Rewrite 3.1.x, running php 5.2.x and mysql 5.0.x community.

  1. index.php should be set up in IIS as a default document (same place you find default.asp, index.htm, etc)
  2. edit wp-settings.php
    Find:
    1. <?php

    at the very top of the file.

    Replace with:

    1. <?php
    2. //*****************************
    3. //    IIS FIX
    4. //
    5. $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    6. //*****************************
  3. create the following htaccess file with the Helicon Manager:
    1. RewriteEngine On
    2.  
    3. #RewriteBase /
    4.  
    5. RewriteCond %{REQUEST_FILENAME} -f [OR]
    6. RewriteCond %{REQUEST_FILENAME} -d
    7. RewriteRule . - [L]
    8. RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    9. RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    10. RewriteRule . /blog/index.php [L]

    • Note: You may need to alter the RewriteBase or the last rule to your specific location. In my particular case, I was installed on domain.com/blog/

From here, you can edit your permalink structure as you normally would. If the default options has index.php/ as part of the rule, you can remove that.

3 comments

Gravatar #1. Small Business Blog
5 months and 3 days ago

Always good to learn more about .htaccess - thanks!

Gravatar #2. konteyner
3 months and 17 days ago

thank you..

Gravatar #3. su kaçağı
1 month ago

thanks..

Write a comment

If you want to add your comment on this post, simply fill out the next form:





* Required fields

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>.

No trackbacks

To notify a mention on this post in your blog, enable automated notification (Options > Discussion in WordPress) or specify this trackback url: http://​skeymedia.com/​permalinks-iis-isapi/​trackback/