ISAPI Rewrite 3.x with WordPress and IIS 7

I recently moved my site over to a Windows 2008 server running IIS 7 with PHP running in FastCGI. Decent speed improvement but I have some more work to do, more on that later. Maybe I’ll even include an install guide for PHP in FastCGI with IIS7. In the move I forgot to setup ISAPI_Rewrite which re-writes my URL’s into more friendly and readable text. Great for search engines and people alike. Since I had to setup ISAPI_Rewrite all over again I decided to run through a brand new install. Here is a quick and easy guide to get you started with ISAPI_Rewrite on IIS 7? for Windows Server 2008.

1. Download and install ISAPI_Rewrite from Helicon. http://www.helicontech.com/download-isapi_rewrite3.htm. You can use the lite version but this means your rules will need to be written in the global httpd.conf / .htaccess file, you will not be able to setup per site rules. I suggest buying a license and using the full version with the 45 day trial if you have multiple websites you will be using this with. Download the manual install version since its easiest.

2. After downloading run the installer and extract the files to C:\Objects\ISAPI_Rewrite3. If you purchased a license your license info will go into C:\Objects\ISAPI_Rewrite3\httpd.conf file.

3. Open IIS (Start Menu –> Administrative Tools –> Internet Information Services.

4. Navigate to the site you wish to use ISAPI_Rewrite with and double click on the ISAPI Filters module. Click on add on the upper right hand side.

isapi_filters

Filter Name: ISAPI_Rewrite
Executable: C:\Objects\ISAPI_Rewrite_3\ISAPI_Rewrite.dll

isapi_rewrite

5. Now you need to create a .htaccess file in the root of your domain. The root is the content location for the domain, where all of the web files are.

Find the webroot of your site in IIS by clicking on basic settings.
Find the webroot of your site in IIS by clicking on basic settings.

You can easily create a .htaccess file with an FTP client since Windows Explorer doesn’t like files without a name. I use Filezilla and so should you. Connect to your site with filezilla and upload a simple text document. Right click on the doc and click on rename. Type in “.htaccess” for the file name.

filezilla-rename

6. Back on the Windows 2008 server navigate to the root of your website and open the .htaccess file with notepad. Insert the following rules.What this will do is allow you to post a custom permalink as well as make sure that all visitors are directed to “www” dot your domain name. Basic search engine friendly stuff, good for SEO. You can of course customize this to your heart’s desire, I am just including the most basic rules right now.

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\d+)/[^/]+/?$ index.php?p=$1 [NC,L]

The rules you need to add to the .htaccess file in notepad
The rules you need to add to the .htaccess file in notepad

7. After you save the file login to your wordpress admin and navigate to Settings –> Permalinks. Click on custom and type in /%postname% this will make all your post URL’s look like “http://www.your-domain-name.com/title-of-your-blog-post. You can also add in other custom tags like %post_id% but I like just having my domain name followed by my blog title. Call me a minimalist. Permalink tags here.

Permalinks in your WordPress admin settings
Permalinks in your WordPress admin settings

custom-permalink

8. Make sure to save your settings and your done. To see this in action click on one of your blogs. Here is an example of mine.

How to dump transaction log in MSSQL 2008

ff-URL

Notice my domain name includes “www” and the blog title is directly after the domain with dashes. Looks nice huh? Leave a comment with a link to your own blog and begin some track backs. Maybe more on that later …

1 Comment

 Add your comment
  1. There is obviously a lot to know about this. I think you made some good points in Features also.
    Keep working ,great job!

Leave a Comment

Your email address will not be published.

1 Trackback

  1. ISAPI Rewrite 3.x with WordPress and IIS 7 ? Mike Says Meh « Lisa and Philip Blog (Pingback)