0

我已经阅读了很多文章,但没有一篇能解决我的问题 我用 Asp.net 实现了一个 Web 项目,并将 SSL 证书放在我的网站上。一切正常,但是当我输入https://www.forexample.com它时遇到一个错误,说这个连接不是私有的,但如果我输入https://forexample.com,那么它工作得很好。我不知道我应该如何解决它。

这是我在 web.config 中重定向的规则

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


     <rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
<match url="(.*)" /> 
<conditions> 
    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions> 
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
      </rule>


  </rules>
</rewrite>

它在 system.webServer 中。我想我应该找到一种方法将 https\:www 重定向到非 www 我将不胜感激。

4

1 回答 1

0

您需要能够接受请求https://www才能执行重定向。这意味着您需要一个可以处理该子域的证书。常见的解决方案是获取通配符证书,以便您可以处理*.yourdomain.com. 这将涵盖www您将来希望使用的任何其他子域。

于 2018-08-26T14:55:45.737 回答