0

I'm using this solution in redirecting my domain from non www to www. I'm using azure for hosting.

I have created app service for www.domain.com

enter image description here

when I try to access domain.com I get this error:

enter image description here

Should I have to create two app services one for domain.com and one for www.domain.com? or is there a way to accomplish this using one app service?

Irfan Y
  • 1,242
  • 2
  • 21
  • 68
  • 1
    You don't have to create two app services. Have you added `domain.com` hostname mapping in `Custom DNS` sections for your Web App in Azure Portal? – Gaurav Mantri Feb 11 '18 at 12:28
  • I just added the `domain.com` in `Custom Domains` and it worked. Thanks. Please post as answer so that it would be helpful for others. – Irfan Y Feb 11 '18 at 12:49

2 Answers2

3

Should I have to create two app services one for domain.com and one for www.domain.com? or is there a way to accomplish this using one app service?

No, you don't need two app services to accomplish this.

Assuming you have configured domain mapping correctly in your DNS provider (e.g. GoDaddy), all you need to do is add both www.domain.com and domain.com in the Hostname mapping in Custom DNS section for your Web App in Azure Portal.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
1

All you need to do it set it up in the DNS section of your domain provider and add custom domains in App Service in Azure Portal as well:

Type   Name    Value
A      @       Ip Address of your App Service ( this will cover your main domain )
TXT    @       yourwebsite.azurewebsites.net ( this will cover your main domain )
CNAME  www     yourwebsite.azurewebsites.net ( this will conver www section)

Now in the app service side you need to add the custom bindings.

Go to Azure Portal | App Service | settings | custom domains | add host name as below

yourdomain.com 

Now you have both domain pointing to same App Service. More info on step by step guide, I have prepared a post for custom domain check it out.