Home > Software > Permalinks with ISAPI rewrite for WordPress

Permalinks with ISAPI rewrite for WordPress

January 2nd, 2009

When I started this blog I wanted to have nice looking permalinks for all articles. This means all articles have links like:

http://www.basvandijk.eu/2009/01/01/happy-new-year/

instead of

http://www.basvandijk.eu/?id=3458

I almost got this working except the fact that my URLs contained “index.php” like:

http://www.basvandijk.eu/index.php/2009/01/01/happy-new-year/

After searching through lots of websites I found a solution for this issue.

My virtual hosting provider supports the ISAPI rewrite plugin for IIS. This plugin works the same as mod_rewrite for the Apache server. The only problem was how to activate this plugin? It turned out to be very easy. I just needed to create a httpd.ini in my site root containing the following code:

RewriteBase /
RewriteCond ${REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
# For special WordPress folders (e.g. theme, admin, etc.)
RewriteRule /wp-(.*) /wp-$1 [L]

# For all WordPress pages
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]

Thanks to shoox.nl for providing the code. Shoox.nl uses an extra line of code, but this causes the “preview post” function to stop working.

Software , ,

  1. January 19th, 2009 at 15:24 | #1

    Thanks for linking to my website. I still don’t get how you managed to get the index.php out of your URL, but i’ll have a look at it again some time this week.

    Kind Regards,

    Jaap.

  2. January 19th, 2009 at 17:03 | #2

    Well the fix is when you leave the line:

    RewriteRule /(.*) /\?$1 [L]

    out of the httpd.ini. When I did it worked nice!

  3. January 28th, 2009 at 15:58 | #3

    Thanks for the tutorial, since I’ve been using WordPress for some time now. Just a small problem:

    My host is using IIS and the ISAPI_rewrite module, but only the lite version. According to their site, I quote:
    “This is simplified edition of ISAPI_Rewrite. It does not support per-virtual-site configurations, proxiing, metabase monitoring and automatic cache cleanup but all other features are supported. ISAPI_Rewrite Lite is completely FREE! It may be an ideal solution for the server hosting the only site, development or testing purposes.”

    So instead of my own ‘httpd.ini’, I used the global ‘httpd.ini’, as located in “C:\Program Files\Helicon\ISAPI_Rewrite”. I edited it, to accept your rules, but the ‘index.php’ remains.

    I tried adding a custom permalink structure in WordPress, removing the ‘index.php’, but this only gives me “Page Not Found” errors. Any help?

    Cheers,

    ~Bas

  4. January 28th, 2009 at 16:06 | #4

    In my WordPress settings I make use of the “custom” permalinks option. Using the following structure:

    /%year%/%monthnum%/%day%/%postname%/

    Maybe this helps?

  5. January 28th, 2009 at 18:49 | #5

    Bas :In my WordPress settings I make use of the “custom” permalinks option. Using the following structure:
    /%year%/%monthnum%/%day%/%postname%/
    Maybe this helps?

    Thanks, this indeed helped a fair bit. But not enough, see, having ISAPI_rewrite lite makes the config apply to all websites hosted on that IIS. So once I thought I fixed my site, other sites went nuts. Finally, I came up with various solutions, some more elegant than others, which you can find at my blog:

    http://www.daraja.nl/wordpress/2009/01/28/pretty-wordpress-permalinks/

    Thanks again for getting started. :)

  6. March 11th, 2009 at 12:41 | #6

    For a full walk thru on creating the httpd.ini file and all the bits to make the link work try: http://expressionengine.com/forums/viewthread/29290/

    It works like an absolute treat! :)

  7. March 11th, 2009 at 13:38 | #7

    Thanks for the link!

  1. No trackbacks yet.