Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple external files for url rewrite under web.config

Earlier I wanted to keep the redirects out of web.config, because I have many rewrite rules. I was successfull in doing that by using

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

Now the problem is this file is already having many rules, and I am going to use another set of large amount of rules for another domain pointed to same base code. So I want to keep rules for both files on different files like:-

<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 both domains will have different rules and domain addition can be more too in this project.

Any suggestions will be appreciated ...

like image 681
Luckyy Avatar asked Feb 22 '13 16:02

Luckyy


People also ask

What is the difference between URL Rewrite and redirect?

Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.

What is Outboundrules in Web config?

The outbound rewrite rule can operate on the content of an HTTP header or on the response body content. This rule needs to replace links in the response content so in the "Matching Scope" drop down list choose "Response".


1 Answers

Can you use create multiple files (for development only) and create post-build rules that concatenate them all into the single rewrite.config file?

This way you can split them into multiple files and version control them during development and the post-build will aggregate them into one file for production purposes.

Does the second domain point to the same application in IIS? If they are different applications you could use the config transformation capabilities of VS to have a single file per domain and only deploy the file you need on each application: http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx

like image 73
nimeshjm Avatar answered Oct 31 '22 20:10

nimeshjm