XEN Digital Marketing Blog
Digital Marketing and HubSpot Strategies

Business Growth Blog

Categories Arrow


Each week we share our latest digital marketing and HubSpot experiments, findings, tips and strategies.

Subscribe to Email Updates

Posts by Tag

see all

Recent Posts

Using Rewrite Maps in IIS for 301 Redirects

By Craig Bailey

Published: Tuesday 28 January 2014 | Last updated: Saturday 31 July 2021

(Note: Here's why redirects are so important)

The following steps out line how to set up the redirects using rewrite maps in IIS.

These steps are based on the following blog post and articles from Ruslan Yakushev:

Note: you need to be using IIS7 or above, with ASP.NET role service enabled, AND the URL Rewrite Module installed.

Step 1: Create the rewrite mapping file

This is a text file, saved with the name rewritemaps.config, here’s the example format:

    <rewriteMap name="Redirects">
        <add key="/oldurl" value="/newurl" />
        <add key="/oldurl2" value="/newurl2" />

Step 2: Copy to IIS

Copy the rewritemaps.config file into the same directory as your web.config (on IIS)

Step 3: Add a reference to web.config

Add a reference to the rewritemaps.config file in your web.config file eg:

            <rewriteMaps configSource="rewritemaps.config"></rewriteMaps>
                <rule name="Redirect rule1 for Redirects">
                <match url=".*" />
                    <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
                <action type="Redirect" url="{C:1}" appendQueryString="false" />

Step 4: Load into IIS

Simply make a change to the web.config file and save – this will force the web.config to be reloaded in IIS (and thus for the rewritemaps.config file to be loaded).

You can also recycle the IIS application pool so that the new web.config details are loaded.
Or, you can modify the rewrite rules using the IIS Manager UI and this will reload them (‘touching’ the mapping file via the UI causes it to be reloaded).

Step 5: Increase IIS rewritemaps.config size limit (Optional)

If you have extremely large rewritemaps files (eg with thousands of redirects) they may be larger than the default file size of 256KB.

In this case you will need to set a registry setting to increase the default size allowed. This setting affects web.config and all other .config files (ie the rewritemaps.config files).

Set to: 2048

Note: this requires a server reboot!

For further details see this support knowledge base article:

Note: if you are running 32 bit application pool, you’ll need to use a different reg key, details are available here:

Published: Tuesday 28 January 2014 | Last updated: Saturday 31 July 2021

Tags: SEO
By: Craig Bailey
Craig Bailey

Craig is the founder and CEO of XEN.

Digital Marketing and HubSpot Articles

Recent Blog Posts