IIS7 urlrewrite module - Rules in external xml file

后端 未结 2 730
旧时难觅i
旧时难觅i 2020-12-09 02:31

I\'m using IIS7 UrlRewrite module. I set up my rules in the web.config section. I want to know if there\'s a way to defi

相关标签:
2条回答
  • 2020-12-09 03:02

    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

    0 讨论(0)
  • 2020-12-09 03:14

    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

    0 讨论(0)
提交回复
热议问题