asp.netazureazure-web-rolesazure-web-app-service

How to configure Multiple Azure websites on Single Domain name


I have azure websites like

validation.azurewebsites.net
config.azurewebsites.net

I have domain name www.mydomainname.com which is nothing but my main azure website mydomainname.azurewebsites.net

I want to configure Url in a way like

www.mydomainname.com/validation
www.mydomainname.com/config

url www.mydomainname.com/validation will redirect to azurewebsite validation.azurewebsites.net and url www.mydomainname.com/config will redirect to azurewebsite config.azurewebsites.net

I tried many things like CNAME configuration Manage domain but did not able to achieve this. any clue?


Solution

  • If all you want to do is redirection to an Azure web site, then you should be able to use the built-in UrlRewrite functionality which is available in Azure webapps. The only thing you need to do is add the below section in web.config for your Azure Webapp mydomainname.azurewebsites.net under the <system.webServer> section and the redirection should happen for the two scenarios you mentioned

    <rewrite>
            <rules>
                <rule name="redirectToValidation" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <action type="Redirect" url="http://validation.azurewebsites.net/" appendQueryString="false" redirectType="Found" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{PATH_INFO}" pattern="/validation/*" />
                        <add input="{PATH_INFO}" pattern="/validation" />
                    </conditions>
                </rule>
                 <rule name="redirectToConfig" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <action type="Redirect" url="http://config.azurewebsites.net/" appendQueryString="false" redirectType="Found" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{PATH_INFO}" pattern="/config/*" />
                        <add input="{PATH_INFO}" pattern="/config" />
                    </conditions>
                </rule>
            </rules>
        </rewrite>
    

    There may be better ways of configuring URL Rewrite rules so see what exactly you need and configure the URL-REWRITE rule accordingly.