Subdirectory and subdomain pointers with URL rewrite

To host multiple sites within one site hosting account, and barring conflicting rewrite rules, routing or a site built on the ASP.NET Core Framework, URL rewrite may be used to redirect domains and subdomains to subdirectories on an existing site.  Syntax examples can be found below for each type of redirection.  The rule(s) would be added to the web.config file in the document root of the site.  For Core, see the last section.
 
 
Adding a Domain Pointer
 
Winhost Control Panel > Sites > the domain name > Domain Pointer
 
 
Redirecting a domain to a subdirectory
 
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <rewrite>
   <rules>
    <rule name="domain.com" stopProcessing="true">
     <match url=".*" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="^(www.)?domain.com" />
      <add input="{PATH_INFO}" pattern="^/subdirectory/" negate="true" />
     </conditions>
     <action type="Rewrite" url="\subdirectory\{R:0}" />
    </rule>
   </rules>
  </rewrite>
 </system.webServer>
</configuration>
 
In the above syntax example, "domain.com" on lines 6 and 9 should be replaced by the domain pointer and "subdirectory" on lines 10 and 12 should be replaced by the subdirectory where the files have been uploaded.
 
 
Adding a Subdomain
 
Winhost Control Panel > Sites > the domain name > Subdomain Manager
 
 
Redirecting a subdomain to a subdirectory
 
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <rewrite>
   <rules>
    <rule name="subdomain.domain.com" stopProcessing="true">
     <match url=".*" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="^subdomain.domain.com$" />
      <add input="{PATH_INFO}" pattern="^/subdirectory/" negate="true" />
     </conditions>
     <action type="Rewrite" url="\subdirectory\{R:0}" />
    </rule>
   </rules>
  </rewrite>
 </system.webServer>
</configuration>
 
In the above syntax example, "subdomain.domain.com" on lines 6 and 9 should be replaced by the applicable subdomain and "subdirectory" on lines 10 and 12 should be replaced by the subdirectory where the files have been uploaded.
 
 
If after adding either rule the subdirectory is being appended to the URL, you'll want to verify line 10 in the above syntax has been added to remove it.
 
 
ASP.NET Inheritance
 
Note that if the subdirectory is set as an application starting point and there is an ASP.NET application in the parent directory, the child application will inherit settings from the parent application.  For more information about disabling inheritance, see:  https://stackoverflow.com/a/5968658
 
 
ASP.NET Core
 
Microsoft.AspNetCore.Rewrite is middleware with support for URL rewrite rules.  For an overview on using the middleware, see the microsoft.com article URL Rewriting Middleware in ASP.NET Core.  To use URL rewrite rules like those above through a referenced xml file, see the IIS URL Rewrite Module rules section.