5

Is it possible to prevent access to my Azure website from the Azure provided domain and force the use of the custom domain via a setting/configuration within Azure?

Right now I have a custom domain associated with my Azure Web App.

So, under domain names, there are 2 listed, my custom domain and the azure provided domain.

Example: mywebapp.com mywebapp.azurewebsites.net

I want traffic to only be allowed in via the custom domain. So, mywebapp.azurewebsites.net should either not be allowed or should redirect to mywebapp.com.

ShellyFM
  • 551
  • 3
  • 11

1 Answers1

5

The easiest way is to change your web.config and add a URL Rewrite rule that will do a permanent redirect from the *.azurewebsites.net domain to your domain.

You can find an example on how they do that for domain.com to www.domain.com and you can apply the same logic. This article explains how to do that.

Panos
  • 1,953
  • 1
  • 14
  • 15
  • Where would the URL Rewrite rule be included? The azurewebsites.net URLs won't hit my server as they go straight to Azure, and I don't see a way to do rewrite rules like this on Azure? – user984003 Nov 15 '19 at 20:39