IIS 配置web.config 实现http重定向跳转HTTPS,包括不带www跳转到带www

web.config实现http重定向跳转HTTPS,代码如下:

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

web.config重定向带www的域名转向www域名规则,代码如下

                <rule name="不带www转向www域名规则" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_HOST}" pattern="^xmjdwx.cc$" ignoreCase="false" />
                    </conditions>
                    <action type="Redirect" url="https://www.xmjdwx.cc{R:1}" redirectType="Found" />
                </rule>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
     <!--http转https-->
        <rule name="Redirect to https" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}:443/{R:1}" redirectType="SeeOther" />
        </rule>
        <!--将带www转为不带www-->
        <rule name="WWW Redirect" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www.xxx.com$"/>
          </conditions>
          <action type="Redirect" url="https://xxx.com/{R:0}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

 

人已赞赏
网站主机

腾讯地图 出现“鉴权失败,请传入正确的key”怎么解决?

2020-9-28 23:47:19

网站主机

百度云加速如何把HTTPS访问强制跳转至HTTP

2020-10-8 10:29:13

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索