簡體   English   中英

IIS 7重寫模塊,是否可以以編程方式定義重寫規則,而不是在Web.Config中管理它們?

[英]IIS 7 rewrite module, is it possible to programatically define the rewriting rules rather than manage them in the Web.Config?

我正在開發一個定制的CMS系統,我們的每個客戶都有一個自己的域名,通過它們他們可以訪問我們在系統上的內容。 為此,我們使用IIS重寫模塊來確保每個域都指向每個客戶擁有的內容。

我們的重寫規則的一個示例如下,

    <rule name="ReverseProxyInboundRuleCustomerX" enabled="true" stopProcessing="true">
      <match url=".*" negate="false" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^(www.)?customerx.com" />
        <add input="{REQUEST_URI}" pattern="/Public/([A-Z][a-z].+)" negate="true" />
        <add input="{REQUEST_URI}" pattern="/combres.axd/([A-Z][a-z].+)" negate="true" />
        <add input="{REQUEST_URI}" pattern="/Community/([1-9][0-9])/([A-Z][a-z].+)" negate="true" />
        <add input="{REQUEST_URI}" pattern="/fbchannel.ashx" negate="true" />
      </conditions>
      <action type="Rewrite" url="/Community/10/{R:0}" />
    </rule>

我想做的是通過ASP MVC項目中的代碼動態地以編程方式定義這些規則,而不是依賴於web.config,因為每次我們需要建立新客戶時,都需要有人介入並修改生產服務器。 。

我不想動態地修改web.config,我寧願從web.config中完全消除管理這些規則的責任。

是否可以在代碼中動態聲明這些規則?

您想做什么可以在自定義重寫提供程序中輕松實現。 我們將它們用於大型內容遷移項目已經取得了巨大的成功,在這些項目中,無法選擇基於模式的簡單重寫。

http://www.iis.net/learn/extensions/url-rewrite-module/developing-a-custom-rewrite-provider-for-url-rewrite-module

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM