Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force use of Azure custom domain

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.

like image 579
ShellyFM Avatar asked Apr 23 '15 17:04

ShellyFM


1 Answers

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.

like image 79
Panos Avatar answered Oct 17 '22 19:10

Panos