Internet Information Services
Microsoft web server software.
1,687 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to redirect from http to https://www, I tried the following rule, but unfortunately failed.
<rule name="http to https and www" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" redirectType="Temporary" />
</rule>
Can someone tell me where is the problem?
Hi @aywsdown
You should use two rules to achieve this. one for http to https and another one for https non-www to https www.
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" pattern="^(www\.)?example.com" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" redirectType="Temporary" />
</rule>
<rule name="non-www to www" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.com" />
<add input="{HTTPS}" pattern="^on$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.