Rewrite to a different URL if virtual directory is not there

Topics: User Forum
Sep 2, 2009 at 11:56 AM



I am looking into changing our companies IIS configuration so that we do not have to have several hundred virtual directories, which all redirect to the same site albeit with different CGI parameters.


Our situation right now:

- our website (based on ASP .NET). The website is navigated (built by the server) via CGI parameters (for example:

- we have about 400 (!) virtual directories under the same server which redirect to different menu- and submenuids (for example would redirect to


I would like to use your rewrite filter to handle all requests to virtual directories which are not configured inside IIS.

For example:

We have the main virtual directory (,

The we havesome other virtual dirs (,, which are configured (but the directories inside the filesystem are named entirely different)

The a user comes along and tries to go to, the rewrite should go to (and the site itself looks up the actual menu- and submenuids inside the database. If it cannot find them, it will simply go to the default page)


I have successfully configured your filter so that it does rewrite the virtual directories, but sadly ALL virtual directories, even those which are configured inside IIS.


So, is there a way to tell the filter to rewrite only those virtual directories which cannot be found on the server (and I don't mean looking up the directories inside the file system; they are not there)? Or is it only possible if I enter all configured virtual directories as an exception inside the Rewrite filter ini file?


I hope you understand what I am trying to do, and thank you for your help in advance,




Sep 2, 2009 at 4:50 PM

If you use IIRF v2.0,  then what you want is very easy.  Each vdir gets its own IIRF.ini file, its own set of rewriting rules.

The rewriting you describe - you can specify that in the IIRF.ini file in the "main" virtual directory.   Any URL path that is not mapped to a specific virtual directory, will go to the "main" vdir, right? 

In all the other virtual directories, you would specify a different IIRF.ini file, which does not do the rewriting.


Sep 2, 2009 at 8:22 PM



Thank you for your quick answer. I will try that tomorrow on our testing system. If it works out it could save us a lot of troubles (I could build a small part into our ERP system where our marketing staff can enter the proper ids themselves, instaed of bugging me to set up new virtual directories which simply redirect to the main site).


And also if it works out I will try to coax a donation from our CEO, and if he is not willing I whill shell something out for myself, simply because of the trouble that solution will free me of...


Kind regards,



Sep 2, 2009 at 8:34 PM

nice of you.  Good luck with that.   Why don't you figure the time and trouble it takes for you, and figure how much time using this will save you, over the course of 6 months or so.  A small portion of that savings would be a very generous donation.