I am trying to get a React app on IIS to redirect to https for everything. It is not working at the moment. I can access the application and assets through http and https, but the former won't redirect to the latter.
This is what I started with:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Static Assets" stopProcessing="true">
<match url="([\S]+[.](html|htm|svg|json|js|css|png|gif|jpg|jpeg|map))" />
<action type="Rewrite" url="/{R:1}" />
</rule>
<rule name="ReactRouter Routes" 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>
</rules>
</rewrite>
</system.webServer>
</configuration>
Here is what I have so far:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Static Assets" stopProcessing="true">
<match url="^(http|https):\/\/([\S]+[.](html|htm|svg|json|js|css|png|gif|jpg|jpeg))" />
<action type="Rewrite" url="https://{R2}" logRewrittenUrl="true" />
</rule>
<rule name="ReactRouter Routes" stopProcessing="true">
<match url="^(http|https):\/\/(.*)\/(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="https://{R2}/index.html" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>