Importing mod_rewrite Rules

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

The IIS 7 URL rewrite module enables you to easily convert Apache mod_rewrite rules to IIS URL rewrite rules.

Note

The URL rewrite module tries to convert Apache mod_rewrite rules to functionally equivalent IIS URL rewrite rules. However, because of architectural differences between Apache and IIS, not all mod_rewrite rules can be converted. It is highly recommended that you study a mod_rewrite rule set until you understand its functionality before you begin the conversion process. Then, after converting to IIS URL rewrite rules, review and test the result of the conversion to make sure that the corresponding IIS rewrite rule set provides the same URL rewriting logic.
Note that only rules that follow Apache mod_rewrite syntax can be converted. Any other formats of rewrite rules (for example, ISAPI_Rewrite, Ionic ISAPI Rewrite, IISRewrite, and others) will not be recognized or will be converted incorrectly.

Importing mod_rewrite Rules

This section shows you how to convert mod_rewrite rules into an IIS URL rewrite-specific format by using the Import Rules feature of the URL rewrite module. The converted rules will be put in an IIS Web.config configuration file.

Convert a mod_rewrite rule for use in IIS

  1. Open IIS Manager, and then click URL Rewrite Module.

  2. In the Actions pane, click Import Rules.

  3. Paste the mod_rewrite rules into the Rewrite rules box.

  4. The Tree View tab of the Converted rules group box will show the result of the conversion. You can click the XML View tab to see how the rules will be stored in the Web.config file.

  5. If you select a rule node in the tree view, the corresponding mod_rewrite rule directive will be highlighted in the Rewrite rules box that appears above the rule node that you have selected.

During the conversion of the rules, the rules are assigned default names. To rename an imported rule, follow these steps.

Rename an imported rewrite rule

  1. In the tree view, select the rule that you want to rename.

  2. Right-click the rule and select Rename.

  3. Rename the rule so that it communicates some meaningful information about what the rule does.

  4. In the Actions pane, click Apply to save the converted rules to the Web.config file.

  5. In the Actions pane, click Back to rules to return to the URL Rewrite Module pane.

See Also

mod_rewrite examples (Bing Search)