Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7 urlrewrite module - Rules in external xml file

I'm using IIS7 UrlRewrite module. I set up my rules in the web.config <system.webServer><rewrite> section. I want to know if there's a way to define the rules in one external xml file instead of in web.config file. Thanks.

like image 347
opaera Avatar asked Sep 22 '10 09:09

opaera


People also ask

How do I check if a URL Rewrite module is installed?

Checking if the URL Rewrite module is installed To see if the URL Rewrite module is installed, open IIS Manager and look in the IIS group - if the module is installed, an icon named URL Rewrite will be present.

How do I create a redirect rule in IIS?

IIS Rewrite rule for static 301 page redirect The rewritemaps. config file contains a one-to-one mapping between an old URL and the new URL and looks like below. For StaticRedirects you need to use the first section with the name “StaticRedirects,” which is the same name as you have in your condition.


2 Answers

Yes, you can use the configSource attribute to point to an external file like you can with other web.config sections. In the web.config:

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

And in the rules config file:

<rules>
    <rule name="some rule">
        <!-- rule details here --->
    </rule>
</rules>

You can still even use the IIS manager to edit rules and it'll just work. One minor caveat with this approach: when you make a change and save an external file like this, it will not recycle the application like making a change to the web.config will. So if you're editing a rule and want to see it take effect, you need to manually poke the web.config by making an edit and saving it.

Another reference: Moving IIS7 url rewrite section out of the web.config file

like image 193
Kurt Schindler Avatar answered Sep 24 '22 08:09

Kurt Schindler


You can use the sample URL Rewrite providers that include one for storing those in a separate file, see: http://www.iis.net/learn/extensions/url-rewrite-module/using-custom-rewrite-providers-with-url-rewrite-module

like image 1
Carlos Aguilar Mares Avatar answered Sep 25 '22 08:09

Carlos Aguilar Mares