简体   繁体   中英

Rewrite rule not working for redirection from http to https

Tried below code but it's not working, entered rewrite tag in system.webServer tag in web.config file of c# , Shows error rewrite can not be child element of system.webServer tag, I have also configured this rule in IIS

<configuration>
<system.webServer>
    <rewrite>
          <rules>
            <rule name="Rule1" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                <add input="{HTTPS}" pattern="^OFF$" />
              </conditions>
              <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
            </rule>
          </rules>
        </rewrite>
</system.webServer>
</configuration>

Install Urlrewrite module if its not installed using web platform installer and try to manually add rule using urlrewrite module.

https://www.iis.net/downloads/microsoft/web-platform-installer

https://www.iis.net/downloads/microsoft/url-rewrite

Regards, Jalpa.

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