IIS7 urlrewrite模块 - 外部xml文件中的规则 [英] IIS7 urlrewrite module - Rules in external xml file
问题描述
我正在使用IIS7 UrlRewrite模块。
我在web.config < system.webServer>< rewrite>
部分设置了我的规则。
我想知道是否有办法在一个外部xml文件而不是web.config文件中定义规则。
谢谢。
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.
推荐答案
是的,你可以使用 configSource
属性指向外部文件,就像使用其他web.config部分一样。在web.config中:
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>
在规则配置文件中:
<rules>
<rule name="some rule">
<!-- rule details here --->
</rule>
</rules>
您甚至可以使用IIS管理器编辑规则,它只会起作用。使用这种方法的一个小问题是:当你进行更改并保存这样的外部文件时,它不会回收应用程序,就像对web.config进行更改一样。因此,如果您正在编辑规则并希望看到它生效,则需要通过编辑并保存来手动戳动web.config。
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.
另一个参考:将IIS7重写部分移出web.config文件
这篇关于IIS7 urlrewrite模块 - 外部xml文件中的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!