这是我的 web.config
我有像 www.web1.com 和 www.web2.com (www 是可选的)这样的主要域,需要重写为 sub1.mainsite.com 和 sub2.mainsite.com 并且还有 www.mainsite.com 处于活动状态。
我一直在尝试许多不同的配置,但我没有想出任何可用的东西。
在跟踪中,这很奇怪,因为它将输入显示为空白,因此 Matched 为假。
如果有人能对此有所了解,将不胜感激。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Alegent Rewrite" enabled="true" stopProcessing="true">
<match url="^(www.)?web1\.com(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
</conditions>
<action type="Rewrite" url="https://sub1.thesite.com/{R:2}" logRewrittenUrl="true" />
</rule>
<rule name="Prairie Health" stopProcessing="true">
<match url="^www\.web2\.com(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^web2.com$" />
<add input="{HTTP_HOST}" pattern="^www.web2.com$" />
</conditions>
<action type="Rewrite" url="https://sub2.thesite.com/{R:1}" logRewrittenUrl="true" />
</rule>
<rule name="noextension" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.cfm" logRewrittenUrl="true" />
</rule>
</rewrite>
<defaultDocument>
<files>
<remove value="default.aspx" />
<remove value="iisstart.htm" />
<remove value="Default.asp" />
<remove value="Default.htm" />
</files>
</defaultDocument>
<tracing>
<traceFailedRequests>
<remove path="*" />
<add path="*">
<traceAreas>
<add provider="WWW Server" areas="Rewrite" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="200-399" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>