Microsoft URL Rewrite 101

Pick Language to Auto Translate:
AR | BG | CA | CS | DA | DE | EL | ES | FI | FR | HI | HR | ID | IT | IW | JA | KO | LT | LV | NL | NO | PL | PT | RO | RU | SK | SR | SL | SV | TL | UK | VI | ZH | ZH-TW

Microsoft URL rewrite module is extremely easy to use not like Mod_rewrite!

Requirement: IIS 7


* Rules-based URL rewriting engine.
* Regular expression pattern matching.
* Wildcard pattern matching.
* Global and distributed rewrite rules.
* Access to server variables and HTTP headers.
* Rule templates.
* UI for testing of regular expression and wildcard patterns.
* UI for managing rewrite rules and rewrite maps.
* GUI tool for importing of mod_rewrite rules.
* and much more!

Once this module is installed there are three templates available when you add a new rule and they are:
# User-Friendly URL
# Rule with Rewrite Map
# Request Blocking

With these templates, it will make doing rewrite rule really simple! Plus the UI for testing and importing from mod_rewrite are extremely helpful.

Steps to add new rule:

# Go to IIS Manager
# Select “Default Web Site”
# In the Feature View click “URL Rewrite“
# In the “Actions” pane on right-hand side click on “Add rules…”
# In the "Add Rules" dialog, select the "user-friendly URL" and click "Ok"

That's it!

Create a test page:

Copy the following ASP.NET code and put it in the %SystemDrive%\inetpub\wwwroot\ folder in a file called article.aspx:

<%@ Page Language="C#" %>

URL Rewrite Module Test

URL Rewrite Module Test Page

Server Variable

Original URL:
<%= Request.ServerVariables["HTTP_X_ORIGINAL_URL"] %>

Final URL:
<%= Request.ServerVariables["SCRIPT_NAME"] + "?" + Request.ServerVariables["QUERY_STRING"] %>

Testing the rule

To test that the rule redirects requests correctly, open a Web browser and request the following URL:

will be rewritten as:

There are so much more you can do with it!

You can download it here:

You can get more information here: