'Multiple sub-domain with several App services in Azure
I currently have one App Service with one domain and one wildcard certificate. I have WordPress and using multiple subdomains has worked so far for schools and district. ex District1.contoso.com School1.contoso.com, School2.contoso.com.
Issue now is that the next district has new requirements but we want to use the same domain. This second district will be on a different App Service. Ex. District2.contoso.com, SchoolA.contoso.com, SchoolB.contoso.com, SchoolC.contoso.com.
We have both App Services setup, we have an *Application Gateway with rules and listners and such. We also have a Virtual Machine with IIS to do redirect from an old domain. (Ex. *.oldcontoso.com)
I can't find instructions on how to have the same domain but sub-domains pointing to different App Services. I only found pointing two different domains to two apps but this is not the case.
How do I redirect the sub-domains to different app services. (ps, I expect a repeat with other districts)
Solution 1:[1]
- In order to group your websites, you have to configure the custom domain name for your Azure websites.
- You could use the virtual directory for deploying multiple application to a single Azure Website ( Single Domain), your apps would look like:
contoso.com/District2/,contoso.com/SchoolA/,contoso.com/SchoolB/.contoso.com/SchoolC/
Publish the root project
- Once your solution is ready to deploy, the next step is to publish the root project (Web) to Azure websites.
Set up the Virtual Directory or Application
Before attempting to deploy the second project, go into the Azure Management Portal and configure the details for the IIS virtual directory or application in the website’s configuration. You need to specify the name of the directory, the file system location, and whether you want to mark it as an IIS application. Be sure to save your settings to apply the changes to Azure.
Go to portal > demo-site App Service > Configuration > Path Mappings > Virtual applications and directories. And add the following,


Publish the child project(s)
Once your application is set up, deploy your child projects. Select the same Azure subscription and website that you used for your root project. Include the virtual directory path in the Site Name and Destination URL sections on the Connection tab.
If you only need to publish to a first level folder, i.e to
demo-site\folder, then all you have to do is, change the Type toApplicationin the Path mappings for/folder, and skip the sub-folder entry since you don’t need it. And correct the Site Name and Destination URL in the publish profile accordingly.
Please refer Map an existing custom DNS name to Azure App Service for more details
Updated Answer
- Application Gateway supports multiple applications each listening on different ports
- You can configure path-based routing rules on the application gateway.
- By this the Application gateway will route request to different backend pools, based on the requested path.
- You can also have Rewrite HTTP headers with Application Gateway
Please refer application gateway with path-based routing rules , multiple site hosting , URL Path Based Routing and SO thread for more information.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
