O'Reilly logo

Professional Microsoft IIS 8 by Benjamin Perkins, Dennis Glendenning, Scott Forsyth, Jeff Cochran, Kenneth Schaefer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rewrite Maps

Standard URL Rewrite rules are very powerful when it comes to pattern matches, but what if you want to maintain a list of before/after URL mappings, or if you want a list of values to use in your logic where a pattern doesn't work? That's where rewrite maps come in. A rewrite map is a list of key/value pairs that can be used for substitution in redirects, rewrites, or most any other URL Rewrite rule situation.

Figure 19.10 shows a sample rewrite map, using IIS Manager to manage them.

Rewrite maps are also useful for a list of keys, even if the value isn't used. (You will see some examples of this shortly.) In that case, you can set the value to some arbitrary value, such as 1, as in the following example (displayed as the XML configuration):

<rewriteMap name="ApprovedDomains">
    <add key="www.localtest.me" value="1" />
    <add key="localtest.me" value="1" />
    <add key="staging.localtest.me" value="1" />
    <add key="admin.localtest.me" value="1" />
</rewriteMap>

Creating the actual rewrite map is pretty straightforward. You can create a rewrite map in IIS Manager at the server, site, or subfolder level. You can use IIS Manager to manage rewrite maps by opening IIS Manager, navigating to the place where you want to create the rewrite map, double-clicking on the URL Rewrite icon, and selecting View Rewrite Maps from the Actions pane. This will show you a list of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required