ISAPI Rewrite and WordPress

This blog uses the WordPress blogging platform which I host myself on my Windows server in the US.

However, WordPress support for ‘pretty URLs’ (pretty Permalinks) does not seem to exist Windows servers that use ISAPI Rewrite for re-writing URLs.

An example of a pretty v. ugly URL is:

  • Pretty:
    http://www.example.com/general/isapi-rewrite-and-wordpress
  • Ugly:
    http://www.example.com/?categoryname=general&p=123

URL re-writing is the process whereby you websites’ users (i.e. you guys as readers of my blog) can type in a pretty URL, and because the URL is re-written, the web server finds the right page at the ugly URL and sends it to your screen.

For those that don’t know, this re-writing is considered good practice, because it means that URLs are more aesthetically pleasing to read, easier to remember,  and easier for search engines to find.

[Also, if you are reading this post out of interest rather than for practical advice, then you may be asking what on earth is ISAPI Rewrite? Well it is simply a piece of software which is installed on a webserver that runs a Windows operating system. It allows for URL re-writing and is easily setup with one small file called 'httpd.ini' which is a settings/configuration file that website designers upload to their website.]

Problem

WordPress does not allow for pretty Permalinks customizations to work with a Windows server and ISAPI Rewrite installed to re-writing URLs.

Solution

[Should work with all WP versions, ATW I use 2.71]

  1. Customise your permalinks as you want (at http://yourblog/wp-admin/options-permalink.php)
    e.g. I use custom structure “/%category%/%postname%” - this creates the Pretty Permalink as in the example above. [More information on choosing your Permalinks.]


    Step 1

  2. Install the plugin (how to?) called ‘AskApache RewriteRules Viewer‘. Next, activate the plugin.
  3. Go to your WP Admin Settings page (at http://yourblog//wp-admin/options-general.php) and click on the subpage “AA RewriteRules“.
  4. You will then be presented with a page similar to the one below:


    Step 4

  5. Select all of the text in the big box “All WordPress RewriteRules” and copy it to the clipboard.
    (Left click on the box; CTRL + A [Select all]; CTRL + C [Copy])
  6. Go to my ‘WordPress RewriteRules to ISAPI RewriteRules Converter‘ page:


    Step 6

  7. Paste (CTRL+V) into the big box on the converter page, and click ‘Convert’.
  8. Select all of the converted rewrite rules returned by my utility and copy them into your ‘httpd.ini’ file (the ISAPI Rewrite Configuration file).
  9. Put the httpd.ini file in the root of your web directory, and assuming it’s enabled on the domain, your WordPress should now work with the Pretty Permalinks you setup.

Limitations

If you significantly change the structure of your site, you may have to go through this process again for some links to work on your blog. I, however, have never encountered this problem.

I hope you find this interesting/useful!

Pretty permalinks with ISAPI Rewrite all the way! ;-) Amen.

Possibly Related Posts:

Comments are closed.