在Web.Config中设置动态用户指定的重定向/ FileMapProvider?

时间:2018-08-17 21:38:38

标签: c# asp.net

我有多个使用相同代码库的站点。我希望每个站点都可以具有任意数量的用户指定的重定向,但是当前在使用FileMapProvider(存储在AppData文件夹中的重定向)时,似乎任何重定向指定的过滤器都会过滤到所有站点。我需要找到一种方法,使一个站点的重定向仅用于该站点。

一些示例重定向:

  

www.siteA.com/folderA|/the-file-to-display.html

     

www.siteA.com/testA|/the-file-to-display.html

     

www.siteB.com/testA|/default.aspx

<rule name="RedirectUrls" enabled="true" stopProcessing="true">
 <match url="(.*)" />
 <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
  <add input="{FileMapProvider:{R:1}}" pattern="(.+)" />
 </conditions>
 <action type="Redirect" url="{C:0}" />
</rule>

<providers>
 <provider name="FileMapProvider" type="FileMapProvider, Microsoft.Web.Iis.Rewrite.Providers, Version=7.1.761.0, Culture=neutral, PublicKeyToken=0545b0627da60a5f">
  <settings>
   <add key="FilePath" value="D:\sites\templates\App_Data\redirect.txt" />
   <add key="IgnoreCase" value="1" />
   <add key="Separator" value="|" />
  </settings>
 </provider>
</providers>

0 个答案:

没有答案