mercredi 23 décembre 2020

Site not redirecting from www to https

On IIS7, my website is not redirecting from www.example.com to https://example.com

Instead it tries to open https://www.example.com

Here is the web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
        <rules>
                <clear />
                <rule name="WWW to HTTPS"> 
                    <match url="(.*)" /> 
                    <conditions> 
                        <add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" /> 
                    </conditions> 
                    <action type="Redirect" url="https://example.com/{R:1}" /> 
                </rule> 

                <rule name="HTTP TO HTTPS" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
                </rule>

                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="backend-api/(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{URL}" pattern="^/(backend-api)/.*" />
                    </conditions>
                    <action type="Rewrite" url="http://localhost:3033/{R:1}" />
                </rule>

                <rule name="AngularPageRefresh" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
        </rules>
        <outboundRules>
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>
    </rewrite>
  </system.webServer>
</configuration>

What am I missing?




Aucun commentaire:

Enregistrer un commentaire