【问题标题】:SSL, how to forward the link of to website to SSL included version?SSL,如何将网站链接转发到包含 SSL 的版本?
【发布时间】:2021-01-29 15:31:17
【问题描述】:

我有一个关于 SSL 的小问题。我有一个网站,我们购买了 SSL 并在 web.config 中制定了一些重写规则。但问题是,有时我们无法重定向到 https 版本。当我们使用 https 键入域时,它可以正常工作,但是当我们删除 https 时,我们无法重定向到该站点的安全版本。这是我们的 web.config 文件(为了隐私,我将我们的站点名称挂为 example.com);

 <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
                <rule name="Redirect to www" enabled="false" stopProcessing="true">
                      <match url="(.*)" />
                      <conditions trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^example.COM$" />
                      </conditions>
                      <action type="Redirect" url="{MapProtocol:{HTTPS}}://www.example.com/{R:1}" />
                 </rule>
            <rule name="AngularJS Routes" enabled="true" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />   
              </conditions>
              <action type="Rewrite" url="/" logRewrittenUrl="false" />
            </rule>
                <rule name="Redirect HTTP to HTTPS" enabled="false" stopProcessing="true">
                     <match url="(.*)" />
                     <conditions>
                     <add input="{HTTPS}" pattern="^OFF$" />
                     </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{HTTP_URL}" appendQueryString="false" redirectType="SeeOther" />
               </rule>

                      <rule name="Force non-WWW and SSL" enabled="true" stopProcessing="true">
                          <match url="(.*)" negate="true" />
                          <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
                        <add input="{HTTPS}" pattern="off" />
                          </conditions>
                          <action type="Redirect" url="https://example.com/{R:0}" appendQueryString="true" redirectType="Permanent" />
                     </rule>

          </rules>
        </rewrite>
      </system.webServer>
    </configuration>

我们还可以做些什么来确保每次都重定向到安全版本 (https) 的链接?

【问题讨论】:

    标签: security ssl web-config websecurity


    【解决方案1】:

    您是否使用过这些 Apache、IIS、Tomcat、Nginx 之一?您必须设置让 http 重定向到 https。

    【讨论】:

    • 谢谢回答。我们正在使用 IIS。但是我们如何才能从 https 重定向到 https 呢?
    • 尝试复制这个:
    猜你喜欢
    • 2020-07-16
    • 1970-01-01
    • 1970-01-01
    • 2017-11-21
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 2011-08-24
    • 1970-01-01
    相关资源
    最近更新 更多