none
Azure naked domain redirection to www RRS feed

  • Question

  • Hi All

    I'm using Azure App Service and Azure DNS
    Does anyone knows how to redirect naked domain to www ?

    Raf

    Saturday, July 16, 2016 9:07 PM

Answers

All replies

    • Marked as answer by RAF-P Saturday, March 11, 2017 6:18 PM
    Sunday, July 17, 2016 12:31 PM
  • In Your web.config You must add the rewrite rule:

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

    Sunday, July 17, 2016 11:51 PM
  • Thanks for the reply. This doesn't work because there is not a static IP address available through the Azure CDN.
    Thursday, August 30, 2018 3:15 PM
  • Thanks! I'm using the GUI Rules Engine, and the closest I'm getting is this:

    <rules xmlns="http://www.whitecdn.com/schemas/rules/2.0/rulesSchema.xsd" schema-version="2">
      <rule id="XXXXX" platform="http-large" status="active" version="0" custid="XXXX">
        <description>Redirect my-domain.com to www</description>
        <!--If-->
        <match.referring-domain result="match" value="my-domain.com" ignore-case="true">
          <feature.url-redirect code="301" pattern="/XXXXXX/my-domaincdn/*" value="https://www.my-domain.com/{R:0}" />
        </match.referring-domain>
      </rule>
    </rules>

    Not sure what the equivalent to {HTTP_HOST} is, I thought "Referring Domain" would be, but still not working. Any thoughts?

    https://docs.microsoft.com/en-us/azure/cdn/cdn-rules-engine-reference-match-conditions#request-match-conditions

    Thursday, August 30, 2018 3:20 PM
  • @darrenhe, Sorry for the delay. The initial question was more specific to Azure App Service WebApps, but you are leveraging Azure CDN service; for this, you may take a look at this feedback post and upvote: Naked Domain CDN. Also, checkout the suggestions outlined in this discussion thread: Mapping a CDN to my naked domain.

     

    For more specialized assistance on Azure CDN related questions you may post your questions on Azure CDN forums for receiving inputs from the targeted audience.

    Thursday, September 20, 2018 8:39 AM
    Moderator