1

I have deployed 2 web application on a single azure web app using the virtual application, please refer screenshot below,

Now I want to point custom domain URL as,

main.mydomain.com to app1

and

api.mydomain.com to app2

is it possible? if yes how to achieve that? please help.

Otherwise, I will end up creating no of WebApps for each application? Then is that the only approach?

enter image description here

Keshavdas M
  • 674
  • 2
  • 7
  • 25

1 Answers1

0

According to your description, you want visit main.mydomain.com and redirect to yourwebapp.azurewebsites.net/app1 and same with app2.

If so, you could use the following rule in web.config:

<rewrite>
    <rules>
        <rule name="RedirectTovirtualDirectory" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAny">
                <add input="{HTTP_HOST}" pattern="^main.mydomain.com$" />
            </conditions>
            <action type="Redirect" url="https://yourwebapp.azurewebsites.net/app1/{R:1}" redirectType="Permanent" />
       </rule>
    </rules>
</rewrite>
Joey Cai
  • 18,968
  • 1
  • 20
  • 30
  • Hi Joey, Thank you for your feedback, But in this case, my URL will show as "yourwebapp.azurewebsites.net/app1" post redirection, I do not want that to happen it should show *"main.mydomain.com"* only. so how to achieve that? – Keshavdas M Sep 25 '19 at 11:44
  • Do you mean you you want visit "yourwebapp.azurewebsites.net/app1" and redirect to "main.mydomain.com"? – Joey Cai Sep 26 '19 at 01:27
  • See basically when we put re-direction, in that case, the browser URL also will get changed, so I do not want that to happen, so my requirement is when I want to point my custom domain to azure app URL it should show my custom domain name only, so basically the website deployed under app1 should be browsed using *main.mydomain.com* – Keshavdas M Sep 26 '19 at 06:31
  • It‘ impossible use web.config to configure custom domain to your app and not change url. you could use [application gateway with path-based routing rules](https://learn.microsoft.com/en-us/azure/application-gateway/create-url-route-portal) to manage with url path. – Joey Cai Sep 26 '19 at 09:04
  • So, I really recommend you to create two webapp for each application. – Joey Cai Sep 26 '19 at 09:33
  • Any update now? If my reply helps you, you could accept it as answer. – Joey Cai Sep 30 '19 at 06:57
  • if I create a web app for each application, I end up creating number of web apps, which is not cost-effective also? so there is no alternative to it? – Keshavdas M Sep 30 '19 at 09:26
  • Azure app service cost depends on the level of your app service plan. So, a signal webapp cost is equal with multiple webapps. If you use application gateway, it is more expensive than app service plan. – Joey Cai Sep 30 '19 at 09:31
  • After all, no custom domain configuration can touch the URI paths. Also the redirect rules executed at application level will make user browsers request a different url, thus the address shown will change. So, it not satisfy your demand. – Joey Cai Sep 30 '19 at 09:32
  • Ok thanks, Joey, I will try and post-confirmation I will accept this so that anyone referring will be guaranteed getting the correct result – Keshavdas M Sep 30 '19 at 09:34
  • Any update now? If it helps you, please mark it as answer. – Joey Cai Oct 14 '19 at 02:16