Iis – Adding multiple web sites on IIS with single DNS name

iisiis-7

I'm trying to add a new web site on an existing IIS v7 which has its default web site installed. My problem is that I have conflict since I can't give:

Different host name
Different local IP
Different port
I was asked to try and do the following. Lets say the default web site can be accessed through www.something.com, than I should try to configure the new web site with www.something.com/new_web_site

Is it possible from the web site configuration?

Is it possible to put some kind of redirect page in a sub folder name new_web_site under the default web site physical location that will redirect the real physical location of the new web site files?

Best Answer

A combination of ARR and rewrite rules will solve this nicely. Here's the steps to follow:

  1. Download and install ARR http://www.iis.net/download/ApplicationRequestRouting
  2. In IIS Manager, select your machine in the Connections pane, double-click the Application Request Routing feature in the IIS section, click on the "Server Proxy" link in the Actions pane, then check the "Enable proxy" checkbox and choos the Apply action.
  3. Change the bindings of your two existing websites--For instance, bind the Released website to port 81, and the Experimental website to port 82.
  4. Create a new website and apppool, and bind it "http:*:80:". Name it "Default Web Site". Point it's physical path to "%SystemDrive%\inetpub\DefaultWebSite"
  5. Create a web.config file for the "Default" website, and write your routing rules there:

    <rules>
        <rule name="Reverse Proxy for Experimental" stopProcessing="true">
            <match url="^.*/experimental/.*" />
            <action type="Rewrite" url="http://{HTTP_HOST}:82/{R:0}" />
        </rule>
        <rule name="Reverse Proxy for Release" stopProcessing="true">
            <match url=".*" />
            <action type="Rewrite" url="http://{HTTP_HOST}:81/{R:0}" />
        </rule>
    </rules>
    
  6. You may have to fiddle somewhat with your rewrite rules, you can experiment using the URL Rewrite Module applet on IIS, and read more about it here: http://learn.iis.net/page.aspx/500/testing-rewrite-rule-patterns/ For further help be sure and browse Ruslan Yakushev's blog: http://ruslany.net/

This will give you three completely separate websites, accessibly through a single facade on port 80 (though of course you can hit each website directly on port 81 and 82 if you need to: http://localhost:81/default.aspx for example.