Using URL ReWrite to host multiple sites/domains under a single site

Scott Forsyth has a couple of good blog posts with pointers on using URL ReWrite to host multiple sites/domains under a single site:

http://weblogs.asp.net/owscott/archive/2010/01/26/iis-url-rewrite-hosting-multiple-domains-under-one-site.aspx
http://weblogs.asp.net/owscott/archive/2010/05/26/url-rewrite-multiple-domains-under-one-site-part-ii.aspx

Be Sociable, Share!

    1 Comments.

    1. I set up all three of my alias domains with the following rule:

      <rule name="Alias Domains" patternSyntax="ECMAScript"
      stopProcessing="false">
      <match url="^([^?]*)" />
      <conditions logicalGrouping="MatchAll"
      trackAllCaptures="true">
      <add input="{HTTP_HOST}"
      pattern="killstone|raggedbay|musicalcollective" />
      <add input="{REQUEST_URI}"
      pattern="^killstone|^raggedbay|^musicalcollective"
      negate="true" />
      </conditions>
      <action type="Rewrite" url="{C:0}/{R:0}"
      appendQueryString="true" logRewrittenUrl="true" />
      </rule>

      Then, I added a second rule to handle "pretty permalinks" in my subdomain’s WordPress instances:

      <rule name="Alias WordPress" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll"
      trackAllCaptures="false">
      <add input="{HTTP_HOST}"
      pattern="killstone|raggedbay" />
      <add input="{REQUEST_FILENAME}" matchType="IsFile"
      negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory"
      negate="true" />
      </conditions>
      <action type="Rewrite" url="{C:0}/index.php"
      logRewrittenUrl="true" />
      </rule>

      The only caveat is that the pretty URLs rewrite only works on sub-folders if you use a trailing slash. So, in order to log into the WordPress dashboard, you need to go to /wp-admin/ (not just /wp-admin).