【问题标题】:web.config force redirect of www to non-www with httpsweb.config 使用 https 强制将 www 重定向到非 www
【发布时间】:2017-03-30 05:06:43
【问题描述】:

所以目前我的主域工作正常,如果我去 www.domain.com 它重定向到https://domain.com

我的子域是问题所在。我也有一个用于 *.domain.com 的通配符 SSL

如果我转到 www.sub.domain.com,它会重定向到具有无效 SSL 证书的 https://www.sub.domain.com,我正试图让它从以下位置加载:www.sub.domain.com 到 https://sub.domain.com 但是我有一些问题。 Godaddy 没有任何帮助,因为它们中的大多数似乎都是“新”的。不幸的是,使用 Plesk 托管。目前我的 web.config 是:

<configuration>
<system.webServer>
<rewrite>
    <rules>
    <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>
</configuration>

【问题讨论】:

    标签: redirect https web-config plesk no-www


    【解决方案1】:

    检查域托管设置,例如“首选域”和 301 重定向到 HTTPS:

    如果你没有 301 重定向到 HTTPS,你可以删除这个 web.config。

    【讨论】:

      【解决方案2】:

      当您安装了一级证书(例如:level3.level2.level1.domain.com)时,通配符SSL证书不能在二级子域上工作。

      您不能在子域之前使用 WWW。我建议您参考我之前对同一问题的回答。

      https://stackoverflow.com/a/37959152/4649681

      希望这会有所帮助。

      【讨论】:

        【解决方案3】:
        <rewrite>
           <rules>
               <clear />
               <rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
                 <match url="(.*)" />
                 <conditions logicalGrouping="MatchAny">
                   <add input="{HTTP_HOST}" pattern="^yourwebsite\.com$" negate="true"></add>
                   <add input="{HTTPS}" pattern="off" />
                 </conditions>
                 <action type="Redirect" url="https://yourwebsite.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
               </rule>
             </rules>
             <rewriteMaps>
               <rewriteMap name="MapProtocol">
                 <add key="on" value="https" />
                 <add key="off" value="http" />
               </rewriteMap>
             </rewriteMaps>
           </rewrite>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-08-20
          • 1970-01-01
          • 2022-03-04
          • 2018-03-31
          • 2016-09-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多