【问题标题】:IIS hosted web application works fine with ssl without www, gives 404 error with wwwIIS 托管的 Web 应用程序可以在没有 www 的情况下使用 ssl 正常工作,使用 www 会出现 404 错误
【发布时间】:2021-06-21 00:45:39
【问题描述】:

早上好。 我在 Windows Server 2016 上使用 IIS 托管了一个 Web 应用程序(如果有用,则使用 Angular 制作),其证书(使用 Let's Encrypts wacs 制作)可与 ssl 配合使用。 问题是,如果我使用 www,该网站不仅看起来不安全,而且还会出现 404 错误。 我在 web.config 上尝试了以下规则以重定向到非 www 但没有成功

<rule name="Redirect WWW to non-WWW" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" />
      </conditions>
      <action type="Redirect" url="https://example.com/{R:1}" />
</rule> 

我还有其他规则,这是我完整的 webconfig 文件:https://pastebin.com/wRWarfCV

【问题讨论】:

  • 清除缓存并重试。你能告诉我你想重定向哪个网址吗?请检查参数^example\.com$是否与您的url匹配,如果仍然不起作用,您只能使用失败请求跟踪来获取详细的错误信息
  • @samwu 我检查了模式,它是正确的。我正在尝试将所有以 www 开头的请求重定向到没有 www 的请求。例如,我正在尝试将 example.com(这给我错误 404 和不安全证书)重定向到 example.com

标签: ssl web redirect iis http-status-code-404


【解决方案1】:

我认为https://www.example.comhttps://example.com 是不同的域。您需要重新颁发证书并添加http://example.com作为主域并添加其他域http://www.example.com

更多信息可以参考这个链接:How do I reissue my SSL certificate?

【讨论】:

    猜你喜欢
    • 2012-06-05
    • 2020-04-01
    • 2016-10-14
    • 2019-05-23
    • 1970-01-01
    • 2015-07-29
    • 1970-01-01
    • 2014-03-19
    • 1970-01-01
    相关资源
    最近更新 更多