Permalinks with ISAPI rewrite for WordPress

Permalinks with ISAPI rewrite for WordPress

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.

7 thoughts on “Permalinks with ISAPI rewrite for WordPress

  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. Well the fix is when you leave the line:

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

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

  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. In my WordPress settings I make use of the “custom” permalinks option. Using the following structure:

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

    Maybe this helps?

  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. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *