We need to be able to run two versions of one ASP.net web application on the same intranet server and port number, but with one mapped to / and the other mapped to /experimental (not real names, but close enough).
C:\inetpub\wwwroot\Version1 => http://test1.organization.com/ C:\inetpub\wwwroot\Version2 => http://test1.organization.com/experimental
The first URL has already been exposed to some beta users and therefore needs to be kept somewhat stable. The second will contain experimental code that only users going to /experimental will see. We don't have the option of using a different server or a different port.
I've achieved this in the past by having / mapped to a site under Sites in IIS, then adding the second site as an application underneath it, and aliasing it to /site2.
Server Sites Default Web Site <= physical path mapped to first version and / / Application1 <= nested application mapped to second version and /experimental
However, this seems sloppy. Would it be cleaner to do this with a rewrite rule or with ARR? If so, how?
A combination of ARR and rewrite rules will solve this nicely. Here are the steps to follow:
http:*:80:
. Name it "Default Web Site". Point its physical path to "%SystemDrive%\inetpub\DefaultWebSite"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>
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).