需要帮助找出这个重写规则

时间:2013-10-07 23:57:34

标签: url-rewriting iis-7.5 url-rewrite-module

这是我的web.config

我有主要域名,如www.web1.com和www.web2.com(www是可选的),需要重写到sub1.mainsite.com和sub2.mainsite.com,并且还有www.mainsite.com活跃。

我一直在尝试许多不同的配置,但我还没有提出任何可用的配置。

在跟踪中它很奇怪,因为它将输入显示为空白,因此匹配为假。

如果有人能够对此有所了解,我们将不胜感激。

<?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>

1 个答案:

答案 0 :(得分:0)

我明白了。

            <rule name="SiteRewrite" enabled="true" stopProcessing="true">
                <match url="(.+)?" ignoreCase="true" />
                <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="(www.)?web1.com" />
                </conditions>
                <action type="Redirect" url="https://sub1.thesite.com/" logRewrittenUrl="true" />
            </rule>