Skip to content

How to deal with the web.config size limit in order to add URL redirects

dessyordanova edited this page Nov 10, 2016 · 1 revision

We will use the URL Rewriter for .NET library to create a module for adding URL redirects in an external file since the web.config file has a limit.

1. In the web.config file add the following changes to include the rewriter module:

<configuration>
	<configSections>
		<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
	</configSections>
	
	<system.web>
    	<httpModules>
     	 <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
    	</httpModules>

  	</system.web>

	<rewriter configSource="urlrewriter.config"> 
	</rewriter>
  
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
		<modules runAllManagedModulesForAllRequests="true">
            <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
		</modules>
  </system.webServer>
</configuration>

2. Create bin folder and put the Intelligencia.UrlRewriter.dll:

url-rewriter-bin

3. Use an external file (urlrewriter.config) to put all redirects indicating which URL to which one to be navigated:

external-config

redirect-syntax