Jump to content

Archived

This topic is now archived and is closed to further replies.

lilmer

Force www on HTTPS

Recommended Posts

Anyone know how to force URL with SSL with www.

 

 <rewrite>
            <rules>               
                  <rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions><add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.site.com/{R:0}" redirectType="SeeOther" />
</rule>       
            </rules>
 </rewrite>

Please check the sample.
 

http://site.com to https://www.site.com

http://www.site.com to https://www.site.com

 

But when 

https://site.com to https://site.com

it doesn't add www on the site URL.

Anyone can help me.

Share this post


Link to post
Share on other sites

Anyone know how to force URL with SSL with www.

 

 <rewrite>
            <rules>               
                  <rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions><add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.site.com/{R:0}" redirectType="SeeOther" />
</rule>       
            </rules>
 </rewrite>
Better try this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="www.fabrikam.com" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://www.fabrikam.com/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.