移动< httpredirect>在单独的配置文件中的web.config之外 [英] Moving <httpredirect> out of web.config in separate config file

查看:431
本文介绍了移动< httpredirect>在单独的配置文件中的web.config之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的web.config中有很多(超过100个)重定向,例如

We have many (more than 100) redirects in our web.config like

<configuration>
   <system.webServer>
      <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
         <add wildcard="/a" destination="/a/dfdf/default.htm" />
         <add wildcard="/sad" destination="/aasd/dfdf/defsadault.htm" />
         <add wildcard="/asdsaa" destination="/aasdas/dfasddf/default.htm" />
         <add wildcard="/aasdsa" destination="/asdsaa/dfdf/defsdault.htm" />
         <add wildcard="/aasd" destination="/adsa/dfdf/default.htm" />
..... more than 100
      </httpRedirect>
   </system.webServer>
</configuration>

我们是否可以在单独的web.config或任何其他最佳解决方案中管理此部分?

Is there way we can have this section managed in separate web.config or any other best solution?

推荐答案

您可以将一些配置元素移动到自己的配置文件中,以减少web.config中的混乱。

You can move some config elements into their own config file to reduce clutter in the web.config.

<configuration>
   <system.webServer>
      <httpRedirect configSource="httpRedirects.config" />
   </system.webServer>
</configuration>

这是通过添加如上所示的configSource属性来实现的。

This is achieved by adding the configSource attribute as shown above.

在单独的httpRedirects.config中

And in your seperate httpRedirects.config

<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
     <add wildcard="/a" destination="/a/dfdf/default.htm" />
     <add wildcard="/sad" destination="/aasd/dfdf/defsadault.htm" />
     <add wildcard="/asdsaa" destination="/aasdas/dfasddf/default.htm" />
     <add wildcard="/aasdsa" destination="/asdsaa/dfdf/defsdault.htm" />
     <add wildcard="/aasd" destination="/adsa/dfdf/default.htm" />
</httpRedirect>

注意我只尝试过其他配置元素。

Note I have only tried this with other config elements.

这篇关于移动&lt; httpredirect&gt;在单独的配置文件中的web.config之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆