0

i have a website and one virtual directory called prog .looking an iis redirect rule for the following condition.

1.i need to redirect all non www http request http://domain/prog  to https://www.domain/prog
2.redirect http  www request http://www.domain/prog to https://www.domain/prog
3.redirect https://domain/prog  to  https://www.domain/prog

i have follow the below url iis url redirect http to non www https

but one condtion not working

https://domain/prog  to  https://www.domain/prog


<rewrite>
<rules>
  <rule name="SecureRedirect" stopProcessing="true">
    <match url="^(.*)$" />
    <conditions>
                    <add input="{HTTPS}" pattern="off" />
                    <add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" />
    </conditions>
    <action type="Redirect" url="https://www.{C:2}/prog" redirectType="Permanent" />
  </rule>
</rules>

Community
  • 1
  • 1
justintjacob
  • 193
  • 1
  • 6

1 Answers1

0

i have applied url rewrite on prog Virtual directory and its worked

<rewrite>
        <rules>
            <clear />
            <rule name="Redirect non-www OR non-https to https://www">
                <match url=".*" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{HTTP_HOST}" pattern="^domain.com$" />
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://www.domain.com/prog/{R:0}" redirectType="Permanent"/>
            </rule>
        </rules>
    </rewrite>
justintjacob
  • 193
  • 1
  • 6