Web.config rewrite rule http to https and angular route combination

Viewed 167

I have the following rewrite rules at IIS for an angular application:

<rewrite>
    <rules>
        <rule name="Angular Routes1" 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="index.html" />
        </rule>
        <rule name="HTTPS Redirect" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTPS}" pattern="^OFF$" />
            </conditions>
            <action type="Redirect" url="https://www.example.com{REQUEST_URI}" appendQueryString="false" />
        </rule>
    </rules>
</rewrite>

When someone browses http://www.example.com, its being redirected to https://www.example.com, but when I use a route that setup the website, for example:

http://www.example.com/layout/dark it is not redirecting to https://www.example.com/layout/dark

I am wondering if Im making a mistake when adding two rules, and it should be all added into one rule.

Thanks.

1 Answers
Related