Subdomain Folder Outbound Rules

Discussion in 'Site Programming, Development and Design' started by PhilB, Apr 14, 2013.

  1. I have a Training Subdomain to my main site which is www.StrategyKpi.com
    So the site has a folder called TrainingSubdomain (just like that with capital T and S).
    So when a user enters http://Training.StrategyKpi.com it shows the Default.aspx file from the TrainingSubdomain folder, and it all looks wonderful.

    However because the outbound links are not working when the Default.aspx file references a link to another file in the same folder, the user sees the following...
    Training.StrategyKpi.com/TrainingSubdomain/OtherFile.aspx

    I have set the folder TrainingSubdomain to be an Application, that way the files in the training folder ignore the root Web.Config inbound rules and focus on the local Web.Config file.
    This being necessary so that
    1. The subdomain code would actually work and find critical files such as the MasterPage.master file and
    2. be able to process outbound rewrite settings from the local Web.Config file.

    So I have tried many times to get the outbound rules working, but without success. I do know that the xml can be case sensitive so have been careful there.
    I have looked at all the Winhost.com forums and also at many places on the web, but without success and yet another 4 hour sessions has been wasted.
    Still the problem persists.
    The Winhost.com forum has a great example that deals with site1, site2 and site3 hosted on the one site, however this does not suit this application.
    Plus they have not bothered to change the actual folder name so that the reader never really knows when they are referring to the site or to the folder. If they had said the site was site1 and the folder was site1folder then it would have been much clearer.

    Please can somebody just simply give me the outbound rules for my Training Subdomain that actually work.

    Root Web.Config file with subdomain inbound rules which work well:
    Note that I have not bothered with the case sensitivity here because there is no folder name other than in the output text.
    <configuration>
    <system.web>
    <customErrors mode="Off" />
    </system.web>
    <system.webServer>
    <httpErrors errorMode="Custom">
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="/Error404.htm" responseMode="ExecuteURL" />
    </httpErrors>
    <rewrite>
    <rules>
    <rule name="strategykpi.com" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^(www.)?strategykpi.com$" />
    <add input="{QUERY_STRING}" pattern="^/strategykpi/" />
    </conditions>
    <action type="Rewrite" url="\strategykpi\{R:0}" />
    </rule>
    <rule name="training.strategykpi.com" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^training.strategykpi.com$" />
    <add input="{PATH_INFO}" pattern="^/trainingsubdomain/" negate="true" />
    </conditions>
    <action type="Rewrite" url="\trainingsubdomain\{R:0}" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>

    So here is the TrainingSubdomain Web.Config file with the outbound rules.
    "We do not have any *.axd files.
    <configuration>
    <system.web>
    <customErrors mode="Off" />
    </system.web>

    <system.webServer>
    <rewrite>
    <outboundRules>
    <rule name="Outgoing - URL paths" preCondition="Not .axd files" enabled="true">
    <match filterByTags="A, Form, Img, Input, Link, Script" pattern="TrainingSubdomain(.*)" />
    <conditions>

    </conditions>
    <action type="Rewrite" value="{R:1}" />
    </rule>

    <preConditions>
    <preCondition name="Not .axd files">
    <add input="{URL}" pattern="\.axd" negate="true" />
    </preCondition>
    </preConditions>
    </outboundRules>
    </rewrite>
    <urlCompression doStaticCompression="false" doDynamicCompression="false" />
    </system.webServer>
    </configuration>
     
    Last edited by a moderator: Oct 14, 2015

Share This Page