Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
580 views
in Technique[技术] by (71.8m points)

iis 7 - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...