IIS Rewrite Domain & Sub Domains?

Discussion in 'ASP.NET 2.0' started by Pointeman, Feb 26, 2012.

  1. Situation: I'm own a new account at DiscountASP and have the 'Unlimited Subdomain' package for $5/mo. I have 1 IP and need to setup a web.config in the root *directory to direct traffic to the appropriate folder based on the URL.

    ie... You type in your browser "store.mydomainname.com" and the "store" folder serves-up it's "default.aspx" page. Magically everything works perfect.

    ie... You have a program that calls the "update.MyDomainName.com" web service and the "update" folders serves-up it's "service.asmx" page. Again, it's magic...

    So DiscountASP says go to this link. Okay, this link makes URL Rewriting seem simple, that is until I try it. http://weblogs.asp.net/owscott/arch...-hosting-multiple-domains-under-one-site.aspx

    Here's my web host folder structure:

    [Folder Name] * * * * * * * * * * * *[URL in browser] * * * * * * * * * * * [Type of web]
    Root0
    - MyDomainName.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *(web site)
    - store ****** * * * * * * * * * * * * * * *store.MyDomainName.com * *(web site)
    - update *********** * * * * *update.MyDomainName.com * *(web service)

    From the example given at forementioned link, I present my feable attemp at scripting:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    * * <system.webServer>
    * * * * <rewrite>
    * * * * * * <rules>
    * * * * * * * * <rule name="Go to the store" stopProcessing="true">
    * * * * * * * * * * <match url=".*" />
    ****** *<conditions>
    ****** * * <add input="{HTTP_HOST}" pattern="^store.MyDomainName.com$"/>
    ****** * * <add input="{PATH_INFO}" pattern="^/store/" negate="true"/>
    ****** *</conditions>
    * * * * * * * * * *<action type="Rewrite" url="\store\{R:0}"/>
    * * * * * * * * </rule>
    * * * * * * </rules>
    * * * * </rewrite>
    * * </system.webServer>
    </configuration>

    I'll bet I'm close. Ohhh I can feel it...............
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    I'm not an expert at URL Rewrite, but judging from the pattern shown on the blog, change these lines:

    <add input="{PATH_INFO}" pattern="^/store/" negate="true"/>
    <action type="Rewrite" url="\store\{R:0}"/>

    to

    <add input="{PATH_INFO}" pattern="^/MyDomainName/" negate="true"/>
    <action type="Rewrite" url="\MyDomainName\{R:0}"/>

    The rules are based on Regular Expressions, so you might want to take a look at this link:

    http://www.addedbytes.com/for-beginners/url-rewriting-for-beginners/
     

Share This Page