简体   繁体   中英

redirect https://www to https:// through web.config

I want to redirect anything to https://domain.com
I found this code:

  <rewrite>
    <rules>
      <rule name="SecureRedirect" stopProcessing="true">
        <match url="^(.*)$" />
        <conditions>
          <add input="{HTTPS}" pattern="off" />
          <add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" />
        </conditions>
        <action type="Redirect" url="https://{C:2}" redirectType="Permanent" />
      </rule>
    </rules>
  </rewrite>

And its working except on https://www.domain.com
My virtual server is Windows Server 2012 with IIS 8, and the domain is https://kajsystem.com

I would suggest using IIS 8 configurations including using the URL Rewrite module, which can handle forwarding and retain the entire requested URL. There is a fairly comprehensive article on MSDN site covering this:

MSDN redirect on IIS 7 and higher

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM