Hey Guys
I have created and hosted a react node web app on azure VM. I have purchased a wildcard SSL Certificate from azure. I have defined below web.config file for URL redirection.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
<rule name="httptohttps" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://%{HTTP_HOST}%{REQUEST_URI}" />
</rule>
<rule name="non-wwwtowww" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^abc\.com$" />
</conditions>
<action type="Redirect" url="https://www.abc.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Above URL redirection works for only the main page abc.com not for all other pages of the website.
For example, If the user enters http://abc.com/home then the page redirects to https://www.abc.com/home
How it's possible in web.config file