I Need To Make A Change With My IT Support! Call (225) 706-8414

Enable URL Redirects in IIS Using ISAPI_Rewrite

You have an IIS server and need to redirect certain URLs to another page on the hosted website, off-server, etc.

Solution

In Apache, this is done using mod_rewrite. With IIS, this is doable, but you need to install an ISAPI filter. We’ll be using Helicon Tech’s ISAPI_Rewrite filter. There is a free version and a paid version. We’ll use the free version. (As a side-note, ISAPI_Rewrite is designed to be *mostly* compatible with Apache’s mod_rewrite.)

First, let’s download the package.

  1. Go to  Helicon Tech’s website.
  2. Click on Download.
  3. You’ll be presented with various versions. For our example, we’re running IIS on Windows SBS 2003, which is Windows 2003 32-bit. Be sure to choose the freeware version if you are following our example. (The free version of ISAPI_Rewrite has a very specific limitation: It’s server-wide, not site-wide.)
Now let’s install the software:
  1. Double-click on the MSI you downloaded.
  2. Run through the installation wizard. In general, the defaults are fine.
  3. Click Finish when done.

The install wizard will install the filter under C:Program Files and register the filter with IIS. The wizard should have restarted the IIS server, but it’s smart to manually restart it just in case.

You can verify that the filter is installed by performing the following:

  1. Log into the IIS web server.
  2. Start Internet Information Services (IIS) Manager.
  3. Right-click on Web Sites and select Properties.
  4. Click on ISAPI Filters.
  5. You’ll should see ISAPI_Rewrite in the list, as shown below.
Now let’s actually create a rewrite rule. Remember that we’re using the free version, which is server-wide. The server-wide configuration file is located under the ISAPI_Rewrite installation directly, which is C:Program FilesHeliconISAPI_Rewrite for us, in the file httpd.ini. If you view httpd.ini, you’ll see:
[ISAPI_Rewrite]# Defend your computer from some worm attacks
RewriteRule .*(?:global.asa|default.ida|root.exe|..).* . [F,I,O]
So let’s edit this file and create a rewrite rule:
  1. Log into your IIS server.
  2. I noticed a post-install issue that may get you. The httpd.ini file is saved read-only. So if you try to edit it, you won’t be able to save your changes. So right-click the file and deselect read-only. Once done, click Ok.
  3. Open httpd.ini in a text editor.
  4. Update the file so it looks like so:
    [ISAPI_Rewrite]
    # Defend your computer from some worm attacks
    RewriteRule .*(?:global.asa|default.ida|root.exe|..).* . [F,I,O]
    RewriteRule ^/abc/ / [L]
  5. Now go to your website but with the URL www.example.com/abc/. Instead of a 404, you should redirect back to the www.example.com/.
A few things on this. First, when you edit, ISAPI_Rewrite may take a second or two to update. My guess is that the filter is caching the configuration file. Second, there are a ton of more comprehensive examples at the vendor website.

Concerned About Cyber Attacks?

CLICK HERE >

Want to Migrate to the Cloud?

CLICK HERE >
Office 365

Ready to Experience Microsoft Office 365?

Want the latest IT news directly in your inbox? Subscribe now!