【问题标题】:Redirect rule in UrlRewrite module not working as expected IISUrlRewrite 模块中的重定向规则未按预期工作 IIS
【发布时间】:2018-03-15 09:15:22
【问题描述】:

需要将每个非 www 命中重定向到 www url,为此我有以下规则

<rule name="WWW" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^domain\.com$" />
        </conditions>
        <action type="Redirect" url="http://www.{HTTP_HOST}/{R:1}" />
    </rule>

现在做什么 - 它将非 www url 的每一次点击重定向到我的主页 (www.domain.com) 预期 - 它应该将 domain.com/subpage 重定向到 www.domain.com/subpage

【问题讨论】:

  • 您的网站使用 ssl 吗?
  • 不,我们没有使用 ssl

标签: asp.net redirect iis url-redirection url-rewrite-module


【解决方案1】:

你可以试试这个,对我有用

<rule name="www" >
    <match url="(.*)" ignoreCase="true" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^example\.com" />
    </conditions>
    <action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>

【讨论】:

    【解决方案2】:

    问题出在我的新 HAProxy LB 集群上,它自己做某种重定向,重定向规则很好。在 IT 的帮助下修复了它

    【讨论】:

      猜你喜欢
      • 2016-06-10
      • 1970-01-01
      • 1970-01-01
      • 2013-08-11
      • 2020-01-12
      • 1970-01-01
      • 1970-01-01
      • 2018-08-12
      • 2015-02-03
      相关资源
      最近更新 更多