Here’s the problem:
You need to install WordPress on a Windows machine running IIS. I’d never normally do this, but sometimes you just don’t have a choice.
There are plenty of links out there about how to do this, and the one I referred to most was How To Install WordPress on IIS 6.0. It is, more or less, straightforward.
However, there’s an issue with IIS and permalinks.The issue is that if you want to take advantage of the WordPress pretty permalinks, you have to suffer a folder in the path called ‘index.php’. So, instead of the rather lovely:
http://www.yourblog.com/yourcategories/the-best-post-in-the-world/
you have to grit your teeth and accept:
http://www.yourblog.com/index.php/yourcategories/the-best-post-in-the-world/
I don’t know why, I really don’t. I’m not that smart. But I did work out how to fix it. It’s easy enough, but you have to put a couple of rules in the ISAPI ReWrite Engine to deal with the quirks.
First we need to head into our WordPress admin tool, and go to Settings > Permalinks. There, you’ll see the craft insertion of /index.php/ in the links. We need to create a custom permalink and delete the index.php bit. Just like this…

Now save that off and head over to your .htaccess file – we need to weave some magic!
At the bottom of this post is the whole file, but the two lines I particularly want to point out are:
RewriteCond %{REQUEST_URI} !/wp-admin
RewriteRule ^/(.*)/$ /index.php/$1 [NC]
The second line works the juju. It takes the URL from the browser, shoves an /index.php/ into it, and displays the contents. For more on how and why this works, check out http://www.workingwith.me.uk/articles/scripting/mod_rewrite for the basics.
Now the first line is really important, because it tells the server not to do this if we’re in the admin section. If we remove this line, there are all kinds of problems reaching /wp-admin/index.php. Trust me.
I have two other lines in the following code which get rid of index.php from URLS, which stops the google duplicate content issue. They’re always worth having.
Finally, make sure that wherever your site is hosted, that the correct permissions are set on the wp-admin and wp-content directories and their sub-directories. You must have read/write/modify permissions set for internal user accounts.
If you implement these small tweaks, then your WordPress IIS install should work like a charm.
Good luck!
Here’s the code:
# -------------------------------------------------------------------------
# Kickstart the Rewrite Engine and set initial options
# -------------------------------------------------------------------------
RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
RewriteBase
# -------------------------------------------------------------------------
# WORDPRESS, WINDOWS & ISAPI DOCUMENTATION
# -------------------------------------------------------------------------
# These are the WordPress redirects we need in place for a Windows Server
# running PHP & MySQL
# We had some issues configuring ISAPI with WordPress and so here are the
# solutions in case we need them again!!
# -------------------------------------------------------------------------
# PERMISSIONS SETTINGS
# -------------------------------------------------------------------------
# The following folders:
# wp-admin
# wp-content
# MUST HAVE read/write/modify permissions set for internal user accounts
# -------------------------------------------------------------------------
# ESSENTIAL WORDPRESS REWRITES
# -------------------------------------------------------------------------
# Redirects 'www.yourblogsite.com/index.php' to 'www.yourblogsite.com/'
RewriteRule ^/index.php$ / [NC,P,R=301]
# Rewrite 'www.yourblogsite.com/anything/' to 'www.yourblogsite.com/index.php/anything/'
# NB. The user does not see this rewrite.
# Must also go into WordPress > Settings > Permalinks and select 'custom'
# and then REMOVE 'index.php' from the custom URL it generates
# The first line is a condition so it doesn't apply the rule to the wp-admin part of the site
RewriteCond %{REQUEST_URI} !/wp-admin
RewriteRule ^/(.*)/$ /index.php/$1 [NC]
# Finally, redirect 'www.yourblogsite.com/anything/anything/index.php'
# to 'www.yourblogsite.com/anything/anything/'
RewriteRule ^/(.*)/index.php$ /$1/ [NC,P,R=301]
# -------------------------------------------------------------------------
# END OF ESSENTIAL REWRITES
# -------------------------------------------------------------------------
Thanks for watching, kids…
This worked great for me, I didn’t have to set the folder permissions you mentioned but I did have to give IIS_WPG read/execute and read permissions on the htaccess file before it would turn on for me.
Thanks for the great post!
This works. Thanks.
When i did a search for yourblogsite.com threw yahoo i found your post.Thanks.
Show me the link to Yourblogsite.com
i was struggling with this problem from few days, and after search so much stuff i got solution and now i have pretty permalinks
in my self hosted (IIS7+ windows Server)blog.
(Prerequisites: PHP5.0+ Version and FAST CGI SCRIPT – Don’t use ISAPI Filter)
I have made one web.config you need to put that file in your root directory and done.
http://www.geekblogger.org/2010/03/how-to-set-pretty-permalinks-in.html
Permissions set for internal user accounts = which number? 744?
i need help with this.
Very nice article. It works very well. Thanks!
In system.webServer of web.config :
I still got error, it didn’t work !
No need to install any ISAPI filter to remove the index.php from WordPress permalinks.No need of .htaccess file..Use these simple steps to WordPress Permalinks in IIS 6.0 using Custom 404 Redirect for Windows Shared hosting/manas hosting or any windows shared hosting.
http://dotnetcodebytes.blogspot.com/2011/11/remove-indexphp-from-wordpress-on.html
Hello,
Would it be possible for you to explain how the rewrites above would change if, like me, you have your blog located at http://www.domain.com/blog, rather that at the root of the site?
The rewriting works if I use the .htaccess file that is described here (near the bottom):
http://www.appliedi.net/blog/2007/10/30/the-better-way-to-do-permalinks-in-wordpress-on-windows/
But I would like to make sure that everything you have described above is account for. I suspect that this is the problem as when I tried your .htaccess file above, it did not work :(
Thanks
Gary