Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm new to IIS administration, but I need to set up a site that whose site root has multiple directories that are also sites.

For example, say I have site at http://www.example.com

The root directory of that sites has multiple folder for it's content, but also has two other directories, say, /community and /labs.

I want to make these directories be the doc root for separate sites such that you'd access a completely different asp.net site if you went to http://www.example.com/community or http://www.example.com/labs from that if you went to the main site at http://www.example.com.

Really, this would be 3 sites in one directory.

I can see how you could create separate sites using different ports, but I want them all to be on port 80.

Are these subdirectory sites Virtual Sites? I know this is possible to do because our sys admins have set this up for our corporate site, to which I've published many times, but I'm trying to do this myself and I can't get an answer from corporate IT on how they did it. :^)

Thanks, Scott

share|improve this question

3 Answers 3

up vote 5 down vote accepted

This is pretty easy in IIS 7.5

Since a "Web Site", simply put, is just a placeholder with at least 1 endpoint mapping (a Binding), and 1 or more applications.

Create a website (or modify the settings of the Default Web Site). When you expand the web site in the IIS Manager, you'll see a tree of subdirectories, namely the subdirectories in the physical directory that your website root application points to.

Right-click the subdirectory you want to host another application in (eg. "Community") and select Convert to Application. Now you'll be able to configure an alternative Application Pool to serve the content, and you can configure the application individually, independent of (almost) any the feature settings on your root application.

For a more in-depth explanation, visit Mike Volodarsky's blog, he designed the IIS 7 application architecture, so if anyone, he knows what's what :-)

share|improve this answer

In IIS7, each site has a default Application, but you can add sub-Applications quite easily. Just right-click on the site, then click "Add Application." Here you would specify the alias (/community), the application pool (might want to make a new one beforehand), and the path to the physical files on the server.

share|improve this answer

An alternative way that doesn't touch existing sites (as many are created and managed by M$ products automa*g*ically) is a reverse proxy with URL rewrite and/or response patching if necessary:

Reverse Proxy with URL Rewrite v2 and Application Request Routing

The rather lengthy instructions there boil down to:

  • install the IIS rewrite extension
  • add the likes of these lines to the root web.config under /configuration/system.webServer (it's shown how to add them with the InetMgr's UI):
<rewrite>
    <!--route requests-->
    <rules>
        <rule name="Reverse Proxy to webmail" stopProcessing="true">
            <match url="^webmail/(.*)" />
            <action type="Rewrite" url="http://localhost:8081/{R:1}" />
        </rule>
        <rule name="Reverse Proxy to payroll" stopProcessing="true">
            <match url="^payroll/(.*)" />
            <action type="Rewrite" url="http://localhost:8082/{R:1}" />
        </rule>
    </rules>
    <!--patch response HTML-->
    <outboundRules>
        <rule name="Add application prefix" preCondition="IsHTML">
            <match filterByTags="A" pattern="^/(.*)" />
            <conditions>
                <add input="{URL}" pattern="^/(webmail|payroll)/.*" />
            </conditions>
            <action type="Rewrite" value="/{C:1}/{R:1}" />
        </rule>
        <preConditions>
            <preCondition name="IsHTML">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
            </preCondition>
        </preConditions>
    </outboundRules>
</rewrite>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.