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="(.*)" />
        <add input="{HTTP_HOST}" pattern="^old$">
    <action type="Redirect" url="/new/{R:1}" />

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.


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

  • So I need to create new website, create binding, add my new web app there, create redirection rules in new web app and everything will work? – Fedor Jul 25 '13 at 11:50
  • Well, you already have a new website, haven't you? The one you want to redirect to. You can either put your redirect rules under the same site, or a standalone. Doesn't really matter. – jishi Jul 25 '13 at 14:04

As I didn't get satisfactory answer, I set aside this question and kept using HTTP Redirect. But later I gave one more chance to URL Rewrite and finally it works as I expected.

At the IIS top level (webserver level) we just need to set a very simple rule for URL Rewrite module. It can be done using IIS snap-in or manually in config file at %windir%\System32\inetsrv\config\applicationHost.config in <webserver> section.
It looks like this.

        <rule name="redicttonew" enabled="true">
            <match url="^oldapp/registration/register" />
            <action type="Rewrite" url="newapp/registration/register" />

By using URL Rewrite instead of HTTP Redirect I achieve:

  1. Completely remove old site
  2. URL Rewrite can be configured to response with 301 code or to work "silently"
  3. And of course old url changes with new one in the user's browser address bar

Hope my original question and this answer are both clear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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