redirect https url without www to https url with www in web.config

53 Views Asked by At

Can any one tell me about how to redirect https url without www to https url with www in web.config file.

Here is some code that I have tried but I didn't meet my requirement.

<rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^domain.com$" />
                </conditions>
                <action type="Redirect" url="<www.url>/{R:0}" />
            </rule>
            <rule name="Force HTTPS" enabled="true">    
               <match url="(.*)" ignoreCase="false"/>    
               <conditions>    
                  <add input="{HTTPS}" pattern="off"/>    
               </conditions>    
               <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent"/>    
            </rule>
0

There are 0 best solutions below