简体   繁体   中英

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

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.

You can put the http to https rule first and try again. If it still does not work, you can use failed request tracking to view detailed error reasons.

Using Failed Request Tracing to Trace Rewrite Rules .

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