Alternate Web.Config for IIS7 rewriter rules

Is it possible to move the rules created by the IIS7 rewrite module from the root web configuration to your own web configuration file, as you can with the application settings, and if so, how?

+7
module iis-7 rewrite
source share
3 answers

I can't get it to work, but the way to describe it is:

<rewrite> <rewriteMaps configSource="external.config"> </rewriteMaps> </rewrite> 

Then in your external.config file add your rules:

 <rewriteMaps> <rewriteMap ... ... </rewriteMaps> 

You must do this with the entire rewriteMap s section: according to this forum post, you cannot do this with the rewriteMap command: http://forums.iis.net/t/1154113.aspx

+3
source share

This works for me in web.config:

 <system.webServer> <rewrite> <rules configSource="web.rules.config" /> </rewrite> </system.webServer> 

One great thing is that the IIS Configuration Editor respects this external file when editing rules and writes the changes back to the external file.

If you put:

 <system.webServer> <rewrite configSource="web.rules.config" /> </system.webServer> 

it will not work, you will get an HTTP error 500.19 Internal server error:

 Error Code: 0x8007000d Config Error: Unrecognized attribute 'configSource' 

Can someone point the final MSDN help page to the rewrite element and the configSource attribute? The MSDN article on system.webServer does not mention the rewrite element, and I cannot find the MSDN page via google.

+2
source share

I found the configuration documentation but doesn't seem to use the configSource attribute.

I assume that the <rules /> element is implemented as an Information section that has the configSource property, while a <rewrite /> a ConfigurationSection element that does not.

0
source share

All Articles