Is it possible to move the rules created by the IIS7 rewrite module from the root web config into its own web config file like you can with appsettings and if so how?
是否可以将IIS7重写模块创建的规则从根网站配置移动到自己的Web配置文件中,就像使用appsettings一样,如果是这样,怎么办?
3 个解决方案
#1
I can't seem to get it working, but the way it's described is:
我似乎无法让它工作,但它描述的方式是:
<rewrite>
<rewriteMaps configSource="external.config">
</rewriteMaps>
</rewrite>
Then in the external.config file add your rules:
然后在external.config文件中添加您的规则:
<rewriteMaps>
<rewriteMap ...
...
</rewriteMaps>
You have to do this with the entire rewriteMaps section: according to this forum post, you can't do this with the rewriteMap: http://forums.iis.net/t/1154113.aspx
您必须使用整个rewriteMaps部分执行此操作:根据此论坛帖子,您无法使用rewriteMap执行此操作:http://forums.iis.net/t/1154113.aspx
#2
This works for me in web.config:
这在web.config中适用于我:
<system.webServer>
<rewrite>
<rules configSource="web.rules.config" />
</rewrite>
</system.webServer>
One cool thing is that the IIS Configuration Editor respects this external file when you edit the rules and writes the changes back to the external file.
一个很酷的事情是,当您编辑规则并将更改写回外部文件时,IIS配置编辑器会尊重此外部文件。
If you put:
如果你把:
<system.webServer>
<rewrite configSource="web.rules.config" />
</system.webServer>
it won't work, you get HTTP error 500.19 Internal server error:
它将无法正常工作,您收到HTTP错误500.19内部服务器错误:
Error Code: 0x8007000d
Config Error: Unrecognized attribute 'configSource'
Can anyone point to the definitive MSDN help page on the rewrite
element and the configSource
attribute? The MSDN article on system.webServer does not mention the rewrite element and I can't find an MSDN page via google.
任何人都可以指向重写元素和configSource属性的权威MSDN帮助页面?关于system.webServer的MSDN文章没有提到重写元素,我无法通过谷歌找到MSDN页面。
#3
I found configuration documentation but it doesn't seem to cover use of the configSource attribute.
我找到了配置文档,但它似乎没有涵盖configSource属性的使用。
My guess is that the <rules />
element is implemented as a SectionInformation which has a configSource property while the <rewrite />
element is a ConfigurationSection which does not.
我的猜测是
#1
I can't seem to get it working, but the way it's described is:
我似乎无法让它工作,但它描述的方式是:
<rewrite>
<rewriteMaps configSource="external.config">
</rewriteMaps>
</rewrite>
Then in the external.config file add your rules:
然后在external.config文件中添加您的规则:
<rewriteMaps>
<rewriteMap ...
...
</rewriteMaps>
You have to do this with the entire rewriteMaps section: according to this forum post, you can't do this with the rewriteMap: http://forums.iis.net/t/1154113.aspx
您必须使用整个rewriteMaps部分执行此操作:根据此论坛帖子,您无法使用rewriteMap执行此操作:http://forums.iis.net/t/1154113.aspx
#2
This works for me in web.config:
这在web.config中适用于我:
<system.webServer>
<rewrite>
<rules configSource="web.rules.config" />
</rewrite>
</system.webServer>
One cool thing is that the IIS Configuration Editor respects this external file when you edit the rules and writes the changes back to the external file.
一个很酷的事情是,当您编辑规则并将更改写回外部文件时,IIS配置编辑器会尊重此外部文件。
If you put:
如果你把:
<system.webServer>
<rewrite configSource="web.rules.config" />
</system.webServer>
it won't work, you get HTTP error 500.19 Internal server error:
它将无法正常工作,您收到HTTP错误500.19内部服务器错误:
Error Code: 0x8007000d
Config Error: Unrecognized attribute 'configSource'
Can anyone point to the definitive MSDN help page on the rewrite
element and the configSource
attribute? The MSDN article on system.webServer does not mention the rewrite element and I can't find an MSDN page via google.
任何人都可以指向重写元素和configSource属性的权威MSDN帮助页面?关于system.webServer的MSDN文章没有提到重写元素,我无法通过谷歌找到MSDN页面。
#3
I found configuration documentation but it doesn't seem to cover use of the configSource attribute.
我找到了配置文档,但它似乎没有涵盖configSource属性的使用。
My guess is that the <rules />
element is implemented as a SectionInformation which has a configSource property while the <rewrite />
element is a ConfigurationSection which does not.
我的猜测是