Several external files for rewriting URLs in web.config

I used to want to save redirects from web.config because I have many rewrite rules. I was successful at this using

<rewrite> <rules configSource="RewriteRules.config" /> </rewrite> 

Now the problem is that this file already has a lot of rules, and I'm going to use a different set of a large number of rules for a different domain specified in the same base code. Therefore, I want to save the rules for both files in different files, for example: -

 <rewrite> <rules configSource="RewriteRules_a.config" /> <rules configSource="RewriteRules_b.config" /> </rewrite> 

which is not allowed , can anyone suggest how can I fix this situation? Please note that both domains will have different rules, and adding a domain may be more in this project.

Any suggestions would be appreciated ...

+6
source share
1 answer

Can you use the creation of several files (for development only) and create post-build rules that combine them all into one rewrite.config file?

Thus, you can split them into several files and manage versions during development, and the post-assembly will merge them into one file for production purposes.

Does the second domain point to the same application in IIS? If they are different applications, you can use the configuration conversion features for VS to have one file per domain and only deploy the necessary file in each application: http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx

0
source

All Articles