redirect non www url to www url in Azure app service

Buddiz AI 0 Reputation points
2024-05-16T08:40:41.4833333+00:00

I want to redirect non www urls to www url in my application with custom domain added to azure app service, Currently my application is available at both www and non www because I have added 2 custom domains which is example.com and www.example.com. But i wanted to make sure whenever the users visits without www in it, it should be redirected to www.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,407 questions
Azure Startups
Azure Startups
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Startups: Companies that are in their initial stages of business and typically developing a business model and seeking financing.
240 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 21,006 Reputation points
    2024-05-16T14:01:34.9566667+00:00

    @Buddiz AI You may want to know that since Traffic Manager only supports custom domain mapping with CNAME records, and because DNS standards don't support CNAME records for mapping root domains (for example, contoso.com), Traffic Manager doesn't support mapping to root domains.

    To work around this issue, use a URL redirect from at the app level. In ASP.NET Core, for example, you can use URL Rewriting. Then, use Traffic Manager to load balance the subdomain (www.contoso.com).

    To permit the app to redirect non-www requests to www:

    Refer to this doc link for details- https://learn.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting?view=aspnetcore-8.0

    Let us know.

    0 comments No comments