How do I set up an HTTP Redirect rule to redirect all requests for a virtual directory to another virtual directory, when I don't know the hostname or complete URL, and cannot use the URL Rewrite module?

The following redirects should work:

http://host1/app/oldvdir -> http://host1/app/newvdir
http://host1/app/oldvdir/ -> http://host1/app/newvdir/
http://host1/app/oldvdir/login.aspx -> http://host1/app/newvdir/login.aspx
http://host2/app/oldvdir/login.aspx -> http://host2/app/newvdir/login.aspx

I would like to place the redirect rule in the app's root web.config. I have attempted the following rules, but the end result is simply that the redirected vdir gets duplicated on the end of the original vdir until reaching the max URL length, e.g.,

http://host/oldvdir/login.aspx -> http://host/oldvdir/newvdir/newvdir/newvdir/...

Rules in root web.config (I also have tried all sorts of combinations of settings with and without leading and trailing slashes, etc):

<location path="oldvdir">
      <httpRedirect enabled="true" exactDestination="false" httpResponseStatus="Permanent">
        <add wildcard="*/oldvdir/*" destination="/newvdir/"/>

<location path="oldvdir/">
      <httpRedirect enabled="true" exactDestination="false" destination="/newvdir" httpResponseStatus="Permanent"/>

2 Answers 2


Few things you can do.

  1. Delete the virtual directory. Select the folder you want to redirect requests too, and add that as a virtual directory with the old name. So you delete OldVdir, and then create it again as OldVDIR but this time with the source as new vdir.

  2. You can use .asp .aspx to do the redirect. In asp, you can do a response.redirect if you are lazy, or you can do a it properly like this:



It's unfortunate that the MS documentation is so lacking on this subject. Fortunately, I was able to figure this out. I found the $S and $Q terms documented in the IIS6.0 documentation.

  <location path="app/oldvdir">
      <httpRedirect enabled="true" destination="/app/newvdir$S$Q" exactDestination="true"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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