【问题标题】:URL with www causing 404 in IIS带有 www 的 URL 在 IIS 中导致 404
【发布时间】:2016-03-28 17:53:44
【问题描述】:

我在 domain.com 上有一个站点。我最近安装了 SSL 证书,所以我可以使用 HTTPS。

在 IIS 中,我为 http 和 https 创建了 domain.com 和 www.domain.com 的绑定。然后我的 web.config 中有一个 URL 重写规则,它调整每个 url 以指向 https://domain.com

我的问题是,当我访问 http://domain.comhttps://domain.com 时,该网站可以正常工作,但 http://wwww.domain.comhttps://www.domain.com 却不行。这是我的重写规则或绑定的问题吗?

这是我的 web.config 供参考:

<configuration>
<system.webServer>
    <rewrite>
        <rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTPS}" pattern="^OFF$" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
</rule> 
            <rule name="Imported Rule 1">
                <match url="^(register)$" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Redirect" url="https://domain.com/register.php" redirectType="Found" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

【问题讨论】:

    标签: iis url-rewriting iis-7 rewrite


    【解决方案1】:

    我已经用这个代码块解决了这个问题。

      <rewrite>
            <rules>
                <rule name="http to https" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Temporary" />
                </rule>
            </rules>
        </rewrite>
    

    【讨论】:

      猜你喜欢
      • 2017-10-06
      • 2015-02-17
      • 2012-07-28
      • 1970-01-01
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      • 2012-12-25
      相关资源
      最近更新 更多