Redirect your azurewebsites.net URL to your custom domain URL

If you’ve attached a custom domain to your Azure Websites setup, you probably want people and search engine crawlers to use the custom domain URL instead of the free azurewebsites.net URL. You can setup your application’s web.config to include the following.

Add the following to the system.webServer section of your web.config, but make sure you replace the “yourdomain” text with your own domain information.

6 thoughts on “Redirect your azurewebsites.net URL to your custom domain URL

    1. Hi Alam. That error makes me think that your domain’s SSL certificate isn’t setup properly. Can you give me some more info?

  1. Thanks for the info. I’m still new to this so this might be an obvious question but what is the second rule “WWW Rewrite” for?

    1. Hi Jonathan. The WWW Rewrite will force a non-www URL to redirect to the www equivalent. For example, if someone went to “example.com” it would redirect to “www.example.com”. But the rule has two “negates” which will not fire for an already www URL and a localhost URL (for dev purposes).

  2. Really take care with that “.azurewebsites.net” redirect if you have set up a default Traffic Manager profile, because it will ping root of “.azurewebsites.net” and by default expects a status code 200 as response but now gets a 301, thinking your site is down and redirects all traffic to your fallback endpoint.

    Configure your Traffic Manager to ping a path that is not affected by the redirect.

Leave a Reply

Your email address will not be published. Required fields are marked *