Partager via


Hosting multiple domains under one Azure Website

When you have multiple domain names and have only one Azure website, you can use IIS URL Rewrite to host multiple domains. What do you need? At least one Windows Azure website in shared mode.

Add you domain names to this Windows Azure website. This is not possible when you use the free Windows Azure websites.

The following folder structure we need, every domain has his own folder:

  • root.azurewebsites.net
    • domain1
    • domain2
    • domain3

Add to the root folder the file web.config and add the following xml:

 <?xml version="1.0"?>
<configuration>

  <system.webServer>
    <rewrite>
      <rules>
 
        <rule name="domain1.com" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^(www.)?domain1.(com|nl)" />
            <add input="{PATH_INFO}" pattern="^/domain1/" negate="true" />
          </conditions>
          <action type="Rewrite" url="\domain1\{R:0}" />
        </rule>
 
      </rules>
    </rewrite>
  </system.webServer>

</configuration>

In this example we use the IIS rewrite rules to manage the requests for www.domain1.com and www.domain1.nl and forward this to the subfolder domain1. Add as many domains and rules you like.

Need more information about IIS Rewite, please go to Scott Forsyth's Blog.