« Previous Next »

Thread: Use rewrite Map to redirect domains..

Last post 05-01-2009 2:14 PM by Nate49. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 04-24-2009, 8:03 PM

    • Nate49
    • Not Ranked
    • Joined on 04-24-2009, 7:43 PM
    • Posts 2

    Use rewrite Map to redirect domains..

    I have successfully written a rule to redirect a domain name to a different domain/subfolder.  I would like to do the same thing with a rewrite map for multiple different domains to different folders within the site.  Here is my basic rule and I would like to covert this into a map where I can add more:
     <rule name="DomainTest" enabled="false" stopProcessing="true">
                        <match url=".*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTP_HOST}" pattern=".*newDomain.com" />
                        </conditions>
                        <action type="Redirect" url="http://www.myDomain.com/someFolder" redirectType="Permanent" />
                    </rule>
     <rule name="DomainTest2" enabled="false" stopProcessing="true">
                        <match url=".*" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTP_HOST}" pattern=".*anotherDomain.com" />
                        </conditions>
                        <action type="Redirect" url="http://www.myDomain.com/anotherFolder" redirectType="Permanent" />
                    </rule>

    Any help would be appreciated!

    -Nate

  • 04-27-2009, 1:30 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: Use rewrite Map to redirect domains..

    Something like this may help:

    <rewriteMaps>
     <rewriteMap name="domains">
      <add key="newdomain.com" value="somefolder" />
      <add key="anotherdomain.com" value="someotherfolder" />
     </rewriteMap>
    </rewriteMaps>
    <rules>
     <rule name="Redirect by domain">
      <match url=".*" />
      <conditions>
       <add input="{domains:{HTTP_HOST}}" pattern="(.+)" />
      </conditions>
      <action type="Redirect" url=http://mydomain.com/{C:1}/ appendQueryString="false" redirectType="Permanent"/>
     </rule>
    </rules>

    Note that rewrite map lookup is literal, so you cannot use any patterns when specifying domain names in the rewrite map.

    http://ruslany.net
  • 05-01-2009, 2:14 PM In reply to

    • Nate49
    • Not Ranked
    • Joined on 04-24-2009, 7:43 PM
    • Posts 2

    Re: Use rewrite Map to redirect domains..

    Thanks!  It is working for me.  Too bad the map is literal, but I guess I'll work with what I have.

Page 1 of 1 (3 items)
Microsoft Communities