0
votes

I have a website on azure and I am trying to remove some redirect chains... exactly I would like to move from naked domain to www domain in https without passing from the http version.

I do some examples because perhaps I have not explained so good. I have theese redirect chains:

  • http://example.azurewebsites.net -> http://www.example.com/ -> https://www.example.com/
  • http://example.com -> http://www.example.com/ -> https://www.example.com/

If I enable only https on my website the situation get worse and I have this redirect chain:

  • http://example.com -> https://example.com -> http://www.example.com/ -> https://www.example.com/

I do not understand where those redirects are set on azure. How can I move from my naked domain to http://www directly, without passing from http://www domain?

Thank you

1

1 Answers

1
votes

By default, Azure Web App doesn't redirect URL. To redirect from your naked domain to https://www directly, you need to create a web.config in the website root folder, then add the config like below:

<configuration>
<system.webServer> 
<rewrite>
    <rules>
        <rule name="Redirect yourdomain.com to www" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="yourdomain.com" />
            </conditions>
            <action type="Redirect" url="https://www.yourdomain.com/{R:0}" />
        </rule>
    </rules>
</rewrite>
</system.webServer>  
</configuration>