IIS URL重写问题

IIS URL重写问题,iis,urlrewriter,Iis,Urlrewriter,我已经在我们的生产站点上使用UrlRewrite IIS插件大约一个月了 我使用提供的模板/向导创建了一个重定向规则,结果配置如下: <rewrite> <rules> <rule name="CanonicalHostNameRule1" enabled="true"> <match url="(.*)" /> <conditions>

我已经在我们的生产站点上使用UrlRewrite IIS插件大约一个月了

我使用提供的模板/向导创建了一个重定向规则,结果配置如下:

<rewrite>
    <rules>
        <rule name="CanonicalHostNameRule1" enabled="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="^www\.mycompany\.com$" negate="true" />
            </conditions>
            <action type="Redirect" url="http://www.mycompany.com/{R:1}" />
        </rule>
    </rules>
</rewrite>

它一直运行良好,直到今天早上,当该网站开始错误的“太多重定向”。据我所知,配置或基础设施没有任何变化

我禁用了该规则,该站点再次正常运行(尽管显然没有任何重定向)

然后,我重新启用了该规则,现在一切都按预期运行。我没有对规则做任何更改,只是暂时禁用了它


有什么想法吗?插件有问题吗?

我建议设置:


如果您再次出现“指示太多”错误,这可能有助于您追踪问题。

我建议您设置以下设置:


如果您再次出现“指示太多”错误,这可能有助于您追踪问题。

请尝试其他代码,我在我的网站上有并运行完美:

<rule name="Canonical Host Name" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^yourdomain\.com$" />
    </conditions>
        <action type="Redirect" url="http://www.yourdomain.com/{R:0}" redirectType="Permanent" />
    </rule>


我尝试使用添加www,但最终使用了上面的示例。

尝试其他代码,我在我的web上运行的非常完美:

<rule name="Canonical Host Name" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^yourdomain\.com$" />
    </conditions>
        <action type="Redirect" url="http://www.yourdomain.com/{R:0}" redirectType="Permanent" />
    </rule>


我尝试使用添加www,但最终使用了上面的示例。

下面的修复对我有效。我发现我的重写规则已经过时了。另一个域已更改其URL策略,现在正在将所有流量从otherdomain.com重定向到www.otherdomain.com

<action type="Rewrite" url="http://otherdomain.com/abc/{R:1}" />



你看到区别了吗?通过添加“www”,我抢占了其他域重定向。我基本上只是遵守了他们的新政策。

下面的解决方案对我有效。我发现我的重写规则已经过时了。另一个域已更改其URL策略,现在正在将所有流量从otherdomain.com重定向到www.otherdomain.com

<action type="Rewrite" url="http://otherdomain.com/abc/{R:1}" />



你看到区别了吗?通过添加“www”,我抢占了其他域重定向。我基本上只是遵守了他们的新政策。

你在用什么框架?我知道1.1出现了一些特别令人不快的错误,需要重新启动IIS…您运行的是什么框架?我知道1.1中有一些特别令人不快的错误,需要重新启动IIS…谢谢Chris,我一定会这样做。谢谢Chris,我一定会这样做。