WordPress and ISAPI_Rewrite
So being that we use Windows and IIS I thought I would never get permalinks working with wordpress. We have ISAPI_Rewrite installed by default on the servers but I was struggling to get it working. After many hours of searching Google and getting non-working versions I resorted to re-writing the rules myself.
So for reference (and to save anyone else losing a few hours of their life) here is the httpd.ini file contents And here is my permalink string /%year%/%monthnum%/%postname%/
[ISAPI_Rewrite]
RewriteRule /([0-9]{4})/([0-9]{1,2})/ /index.php\?year=$1&monthnum=$2 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?feed=$4&name=$3 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/trackback/?$ /wp-trackback.php\?year=$1&monthnum=$2&name=$3 [I,U,O]
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?category_name=$1&feed=$2 [I,U,O]
RewriteRule /category/(.*) /index.php\?category_name=$1 [I,U,O]
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?author_name=$1&feed=$2 [I,U,O]
RewriteRule /author/?(.*) /index.php\?author_name=$1 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/?(.*) /index.php\?name=$3 [I,U,O]
RewriteRule /feed/(.*) /wp-rss2.php [I,U,O]
RewriteRule /comments/feed/(.*) /wp-commentsrss2.php [I,U,O]


Comments 9 Comments
Your httpd.ini does seem to be correct. Is your host using v1 of ISAPI_Rewrite? Check your permalink structure set in wordpress does not include index.php in it.
RewriteRule /?(.*)/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/ /index.php\?name=$1 [I,U,O] should do what you are wanting.
I just double-checked my permalink structure:
/%postname%/%year%/%monthnum%/
I also just checked the httpd.ini file located in my ftp://IPADDRESS/www/halal.biz/blog/ folder (this is where I have my blog.halal.biz subdomain mapped to).
The contents look like this:
[ISAPI_Rewrite]
RewriteRule /([0-9]{4})/([0-9]{1,2})/ /index.php\?year=$1&monthnum=$2 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?feed=$4&name=$3 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/trackback/?$ /wp-trackback.php\?year=$1&monthnum=$2&name=$3 [I,U,O]
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?category_name=$1&feed=$2 [I,U,O]
RewriteRule /category/(.*) /index.php\?category_name=$1 [I,U,O]
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?author_name=$1&feed=$2 [I,U,O]
RewriteRule /author/?(.*) /index.php\?author_name=$1 [I,U,O]
RewriteRule /?(.*)/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/ /index.php\?name=$1 [I,U,O]
RewriteRule /feed/(.*) /wp-rss2.php [I,U,O]
RewriteRule /comments/feed/(.*) /wp-commentsrss2.php [I,U,O]
this does indeed match w/ what you say I wanted.
I just spoke w/ my hosting provider over their online chat support and the convo went like this:
Me: Want to get rid of index.php in the permalinks of my WordPress posts using ISAPI_Rewrite. I have this working properly w/ one blog also hosted by you (ifweran.com) but not w/ my new blog (blog.halal.biz). perhaps isapi_rewrite not enabled on domain/subdomain? I know something is enabled in association w/ this domain because I am using isapi_rewrite to get my naked domain halal.biz mapped to www.halal.biz because I am trying to use google sites/google app engine to develop the site
Gearhost: Ok on emoment while I check on your IIS configurations
Gearhost: Are you using ISAPI_Rewrite 3x?
Gearhost: I have enabled ISAPI_Rewrite 3x for your blog.halal.biz domain name.
Just checked again, but permalink structure still isn't working.
This post works: http://blog.halal.biz/index.php/ahem-hello-world/2009/06/
This post doesn't: http://blog.halal.biz/ahem-hello-world/2009/06/
Any further thoughts? perhaps the problem is that they enabled ISAPI_Rewrite 3x? For what I did w/ ifweran.com, perhaps what I have going is v1 of ISAPI_Rewrite
The file's contents now look like this:
[ISAPI_Rewrite]
RewriteRule /([0-9]{4})/([0-9]{1,2})/ /index.php\?year=$1&monthnum=$2 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?feed=$4&name=$3 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/trackback/?$ /wp-trackback.php\?year=$1&monthnum=$2&name=$3 [I,U,O]
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?category_name=$1&feed=$2 [I,U,O]
RewriteRule /category/(.*) /index.php\?category_name=$1 [I,U,O]
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?author_name=$1&feed=$2 [I,U,O]
RewriteRule /author/?(.*) /index.php\?author_name=$1 [I,U,O]
RewriteRule /(.*)/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/ /index.php\?name=$1 [I,U,O]
RewriteRule /feed/(.*) /wp-rss2.php [I,U,O]
RewriteRule /comments/feed/(.*) /wp-commentsrss2.php [I,U,O]
I then tried to reload the http://blog.halal.biz/ahem-hello-world/2009/06/ page and got the page cannot be found error. I double checked my permalink and made sure that it was still /%postname%/%year%/%monthnum%/
Anymore ideas?
I went into my httpd.ini file located in
ftp://IPnumber/www/halal.biz/blog/
and it now looks like this:
[ISAPI_Rewrite]
RewriteRule /([0-9]{4})/([0-9]{1,2})/ /index.php\?year=$1&monthnum=$2 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?feed=$4&name=$3 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/trackback/?$ /wp-trackback.php\?year=$1&monthnum=$2&name=$3 [I,U,O]
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?category_name=$1&feed=$2 [I,U,O]
RewriteRule /category/(.*) /index.php\?category_name=$1 [I,U,O]
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?author_name=$1&feed=$2 [I,U,O]
RewriteRule /author/?(.*) /index.php\?author_name=$1 [I,U,O]
RewriteRule /?(.*)/(.*) /index.php\?name=$1 [I,U,O]
RewriteRule /feed/(.*) /wp-rss2.php [I,U,O]
RewriteRule /comments/feed/(.*) /wp-commentsrss2.php [I,U,O]
then I changed the permalink custom structure to just:
/%postname%/
Just tried it out:
http://blog.halal.biz/ahem-hello-world/
Got a "The page cannot be found" error
But, I did just e-mail Gearhost (my hosting provider) because my other site ifweran.com's custom permalink structure no longer works now. This was the one that was working properly using your walkthrough.
In that e-mail I sent them, I did refer to your latest comment. Here's a summary of the e-mail in case you were interested:
- - - - -
I just noticed that my website ifweran.com, a wordpress blog hosted by you, no longer works with its custom permalink structure. Does this have to do with the server move mentioned in the e-mail I am replying to? I did this structure to avoid having the index.php link in the url.
this link works:
http://ifweran.com/index.php/a-customer-service-center-we-would-have-verizons-last-call-memory/2009/03/03/
But this link no longer works:
http://ifweran.com/a-customer-service-center-we-would-have-verizons-last-call-memory/2009/03/03/
I was able to accomplish the non-index.php wordpress URL on ifweran.com by doing two things. One, changing the permalink structure to:
/%postname%/%year%/%monthnum%/%day%/
.. and two) have the following httpd.ini file (which I learned about through some assistance through gearhost's support on this site:http://www.andygambles.com/wordpress-and-isapirewrite) on the server over here:
ftp://69.24.79.249/www/ifweran.com/
The .ini's contents are:
[ISAPI_Rewrite]
RewriteRule /([0-9]{4})/([0-9]{1,2})/ /index.php\?year=$1&monthnum=$2 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?feed=$4&name=$3 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/trackback/?$ /wp-trackback.php\?year=$1&monthnum=$2&name=$3 [I,U,O]
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?category_name=$1&feed=$2 [I,U,O]
RewriteRule /category/(.*) /index.php\?category_name=$1 [I,U,O]
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?author_name=$1&feed=$2 [I,U,O]
RewriteRule /author/?(.*) /index.php\?author_name=$1 [I,U,O]
RewriteRule /?(.*)/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/ /index.php\?name=$1 [I,U,O]
RewriteRule /feed/(.*) /wp-rss2.php [I,U,O]
RewriteRule /comments/feed/(.*) /wp-commentsrss2.php [I,U,O]
The file's been untouched for almost a year. And the blog hasn't been updated in a while and is still version 2.6.1
On a related note, I still am struggling to get the same custom link structure (again, with no index.php file in the url) that worked on ifweran.com also on my halal.biz blog. this blog is subdomain at blog.halal.biz and I'm wondering if there's a server setting to adjust as per Andy Gamble's latest comment on the site I linked to earlier. His specific comment was:
"@shahryar I personally believe it is your server settings. The fact that the sub-domain is actually a sub-folder of the main domain. Are you able to generate the sub-domain as a full domain instead within your hosts control panel?"
The httpd.ini file resides on ftp://69.24.79.249/www/halal.biz/blog/, the contents are:
[ISAPI_Rewrite]
RewriteRule /([0-9]{4})/([0-9]{1,2})/ /index.php\?year=$1&monthnum=$2 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?feed=$4&name=$3 [I,U,O]
RewriteRule /([0-9]{4})/([0-9]{1,2})/(.*)/trackback/?$ /wp-trackback.php\?year=$1&monthnum=$2&name=$3 [I,U,O]
RewriteRule /category/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?category_name=$1&feed=$2 [I,U,O]
RewriteRule /category/(.*) /index.php\?category_name=$1 [I,U,O]
RewriteRule /author/(.*)/(feed|rdf|rss|rss2|atom|rss2_comments)/?$ /index.php\?author_name=$1&feed=$2 [I,U,O]
RewriteRule /author/?(.*) /index.php\?author_name=$1 [I,U,O]
RewriteRule /?(.*)/(.*) /index.php\?name=$1 [I,U,O]
RewriteRule /feed/(.*) /wp-rss2.php [I,U,O]
RewriteRule /comments/feed/(.*) /wp-commentsrss2.php [I,U,O]
And the version of wordpress which is running is version 2.8
Any thoughts?
- - - -
end e-mail
It is possible that each site you create is actual either a sub of a main site of a virtual folder. I have experience of this causing some problems with ISAPI_Rewrite behaviour. Which I would sometimes struggle to get to the bottom of.
Do you know what control panel your host uses?
The only other possible thought I had was is index.php a default document defined on the server?