How to Use URL Rewrite instead of Mod Rewrite in Plesk & IIS

Many websites, including WordPress, Drupal and other scripts written in PHP, all use mod_rewrite to create "clean URLs" or "user-friendly URLs" as they are sometimes called. The problem is that Windows servers running IIS (with or without Plesk) don't support mod_rewrite. But there is a way to get the same functionality using URL Rewrite in IIS.

You typically have to install the IIS Rewrite module on the server, and then setup the rewrite rules (which work slightly different than Apache). It is actually very easy to setup, once you know how.

Note: You will need the appropriate security clearance to accomplish this. If you do not have access, then contact your web host or server administrator, and they can set this up for you.

Installing the IIS Rewrite Module

If it is not already installed, you will need to install URL Rewrite Module for IIS. If you are using Plesk, this can be installed as a Plesk Panel Component. 

Install using Plesk

  1. Login to Plesk (with Admin privileges)
  2. Click on Toots & Settings.
  3. Under the Plesk section, click on Updates and Upgrades.
  4. Click on Add/Remove Components.
  5. Look for IIS URL Rewrite Module.
  6. If it has a red X next to it, it is not installed. Click on the down arrow next to the X, and select Install.
  7. Follow the prompts to complete the installation.

Note: Once it is installed, it cannot be uninstalled, due to websites being dependent on it.

Install Manually

If you do not have Plesk, you can install it manually. 

  1. Visit Using the URL Rewrite Module on the Microsoft website.
  2. Follow the directions in the article.

Setting up the URL Rewrite Rules

IIS's URL Rewrite works differently than the Apache module Mod Rewrite, and this is the main reason why rewrite rules don't work out of the box.

The biggest difference is that Mod Rewrite for Apache uses .htaccess, while IIS's URL Rewrite uses web.config, and the configuration files are structured differently.

Scripts Installed via Plesk

If you install scripts, such as WordPress, directly from Plesk (via their Applications inteface), and have URL Rewrite already installed, Plesk will usually do you the favor and set up the rewrites for you. In this case, you don't actually have to do anything. It just works.

Manually Installed Scripts

If you are installing a script manually, or Plesk doesn't create the rewrite rules for you, you can set them up manually.

URL Rewrite Friendly Script

If your script happens to come with a web.config file with URL Rewrite rules, then you are done. Just make sure the web.config file is uploaded to the root of your website.

Since this is unlikely, you'll probably have to convert the Mod Rewrite rules.

Converting Mod Rewrite to URL Rewrite

What you will need to do is convert the Mod Rewrite rules to URL Rewrite rules.

  1. Open IIS (typically through Remote Desktop).
  2. Select the website you want to modify in the Connections list.
  3. Click on URL Rewrite in the IIS section.
  4. Click on Import Rules...
  5. Paste the Mod Rewrite rules found in your .htaccess file into the Rewrite Rules section.
  6. If there are any incompatible rules, either modify or delete them.
  7. Click on the Apply button in the Actions column.
  8. Click Back to Rules to view the new rules.

You can now see the rewrite rules in IIS, but you can also view the XML version of the instructions in the web.config file located in the root folder of your website.

The rewrite rules should just work at this point. You just have to remember that any rewrite rules that are in the .htaccess file are ignored. Keep this in mind next time you want to modify the rewrite rules to avoid frustration. If multiple people work on the site, it may be a good idea to let them know that and/or leave a comment in the .htaccess file or developer notes, especially if they are used to working on Apache servers.

About the Author

WisTex's picture
Scott M. Stolz

Recommended Content