Andy Gambles

Internet, cloud, business and stuff I find that is interesting or amusing.

  • Home
  • AGUK Solutions Ltd
  • ServerTastic
    • Edit
    • Delete
    • Tags
    • Autopost

    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]

    Tags » httpd.ini isapi_rewrite wordpress
    • 18 October 2005
    • Views
    • 10 Comments
    • Permalink
    • Tweet
    • 10 responses
    • Like
    • Comment
    over 2 years ago Andy Gambles responded:
    Andy Gambles
    @shahryar The original blog entry with some of my comments is at the URL at the end of this tweet.

    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.

    over 2 years ago shahryar (Twitter) responded:
    Green_shirt_india_trip_picture_cropped_atttempt_4_-_face_only_normal
    Andy, thanks for the response. Let me know if there's anything I'm missing in the actions I just took:
    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

    over 2 years ago Andy Gambles responded:
    Andy Gambles
    @shahryar I think it is to do with the sub domain being a sub folder of the main domain. Try RewriteRule /(.*)/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/ /index.php\?name=$1 [I,U,O]
    over 2 years ago shahryar responded:
    Andy, thanks for replying, but still doesn't seem to work. I just pulled my httpd.ini file from my ftp://IP#/www/halal.biz/blog/ (it's amidst all the wordpress files - wp-config.php, etc) made the change, and put it back there.

    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?

    over 2 years ago Andy Gambles responded:
    Andy Gambles
    @Shahryar Have you tried just /%postname%/ and RewriteRule /?(.*)/(.*) /index.php\?name=$1 [I,U,O] to see if this works?
    over 2 years ago shahryar (Twitter) responded:
    Green_shirt_india_trip_picture_cropped_atttempt_4_-_face_only_normal
    Andy, just tried out your advice, but it seems that's not even working.

    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

    over 2 years ago Andy Gambles responded:
    Andy Gambles
    @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?
    over 2 years ago shahryar (Twitter) responded:
    Green_shirt_india_trip_picture_cropped_atttempt_4_-_face_only_normal
    Andy, I had not touched this topic of figuring out why the custom, non-index.php permalink structure wasn't working for my subdomain blog halal.biz.

    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

    over 2 years ago Andy Gambles responded:
    Andy Gambles
    @shahryar I think it may be to do with your hosts folder structure on the server but I can not be certain without seeing the actual settings on the server itself.

    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?

    11 months ago Glenn responded:
    I could kiss you. I've been tearing my hair out looking for this.

    Thank you soooooooo so much

  • Andy Gambles's Space

    Run a couple of internet based companies. I love business and of course like to have fun.

    Follow @andygambles

    Archive

    2012 (13)
    February (2)
    January (11)
    2011 (61)
    December (3)
    November (13)
    October (10)
    September (8)
    August (5)
    July (1)
    June (1)
    May (2)
    April (2)
    March (5)
    February (7)
    January (4)
    2010 (43)
    December (1)
    November (7)
    October (2)
    September (4)
    August (3)
    July (1)
    June (2)
    May (4)
    April (1)
    March (4)
    February (11)
    January (3)
    2009 (32)
    December (7)
    November (6)
    September (5)
    August (1)
    July (4)
    June (8)
    February (1)
    2008 (21)
    October (2)
    September (10)
    August (4)
    July (1)
    May (1)
    April (1)
    February (2)
    2007 (10)
    December (2)
    August (1)
    June (1)
    May (3)
    April (2)
    February (1)
    2006 (13)
    December (1)
    September (1)
    August (1)
    July (3)
    April (2)
    March (1)
    January (4)
    2005 (3)
    November (1)
    October (2)
  • About Andy Gambles

    Run a couple of internet based companies. I love business and of course like to have fun.

    Follow @andygambles

  • Subscribe via RSS
  • My Websites

    • AGUK Solutions Ltd
    • ServerTastic

    Organisations

    • Leeds, York & North Yorkshire Chamber of Commerce
    • Scarborough and District Chamber of Commerce
    • Scarborough Digital Action Group

    Useful Links

    • thetrainline Cheap Train Tickets

    Follow Me

      TwitterFacebookLinkedInTumblr

Theme created for Posterous by Obox