Iis – HTTP redirect with IIS 7.5

httpiisredirectrewrite

I have two intranet ASP.NET MVC web applications hosted in one website which could be accessed by the paths: localserver/old and localserver/new. I've moved logic from the first app to the second app and want that all requests to the localserver/old/exactpath?querystring are being redirected to localserver/new/exactpath?querystring.

What I've tried:

Firstly I've tried to use URL Rewrite, as it was mentiond on iss.net forums.

<rule name="DomainRedirect">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^old$">
    </conditions>
    <action type="Redirect" url="/new/{R:1}" />
</rule>

I've tried to set this rule at the "Default Web Site" level (both web apps hosted there) and at the top level of webserver but no success.

It results in infinite redirection loops. If it is important, old web app has the OldController, so the full path which user requests looks like localserver/old/old/actionname?queryparams

How it works now:

I've installed and set up standard HTTP Redirect module in IIS, but it requires me to keep my old web application at the server.

What I want:

Remove old web app completely and simply set the redirection rule to the new app at the higher level of IIS server. Can this be achieved somehow and if yes there should I place rule and how it must look like.

Best Answer

Add the redirect rules to the new site, and move the binding from the old site to the new site (multiple bindings).