Jump to content

Force www on HTTPS


lilmer

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.

Link to comment
https://forums.phpfreaks.com/topic/292332-force-www-on-https/
Share on other sites

  • 5 months later...

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>
Link to comment
https://forums.phpfreaks.com/topic/292332-force-www-on-https/#findComment-1508789
Share on other sites

Archived

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

×
×
  • 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.