Some website changes caused redirect lists with 400+ URLs. What is the best way to maintain these? Adding them one by one is not a good option. Adding them to the the web-config causes the file to grow to the point of the system being unable to read it.
Is there a way to maintain a separate file with redirects in IIS 8?
From my experience best way is to use rewrite maps:
Create rewriteMaps.config
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/test.aspx" value="/test2.aspx" />
<add key="/aboutus.aspx" value="/about" />
</rewriteMap>
</rewriteMaps>
Create rewriteRules.config
<rules>
<rule name="Rule for Redirects">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
In web.config use configSource
attribute
<rewrite>
<rewriteMaps configSource="rewriteMaps.config" />
<rules configSource="rewriteRules.config" />
</rewrite>
Benefits of this structure
pathA
to pathB
) directly into rewriteMaps.config as key-value pair