IIS7 Rewrite模块规则的备用Web.Config

8

是否可以将IIS7重写模块创建的规则从根网站配置文件移动到自己的Web配置文件中,就像您可以使用appsettings一样?如果可以,该怎么做?


你能让它正常工作吗?我还是一头雾水... - willoller
3个回答

3

我似乎无法让它正常工作,但它的描述方式是:

<rewrite>
   <rewriteMaps configSource="external.config">
   </rewriteMaps>
</rewrite>

然后在external.config文件中添加你的规则:

<rewriteMaps>
  <rewriteMap ...
  ...
</rewriteMaps>

你需要对整个rewriteMap部分进行操作:根据这篇论坛帖子,你不能使用rewriteMap来完成此操作:http://forums.iis.net/t/1154113.aspx

2
你还需要一个重写规则来捕获映射。 <rule name="重写规则"> <match url=".*" /> <conditions> <add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" /> </conditions> <action type="Rewrite" url="{C:1}" /> </rule> </rules> - ScottE

3

以下是我在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.

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:

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.


0
我找到了配置文档,但似乎没有涵盖configSource属性的使用。
我猜<rules />元素被实现为具有configSource属性的SectionInformation,而<rewrite />元素是不具有该属性的ConfigurationSection

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接