Creating 1st Rule

Topics: Developer Forum
Apr 10, 2007 at 6:39 PM
OK, first time user here. I followed the steps on MS to install the filter. That seemed to go well and everything appeared as the instructions said it would in IIS. It says you can put the .dll and .ini file anywhere, so for my convenience, I put them in my web site's /bin folder.

Now, I am trying to create my first rule. All I want is for every request containing "/view?docid=1234" to be sent to "/includes/file.aspx?docid=1234". See, "view" is a Java servlet that I cannot recreate on this system. All it does is direct users to the correct document. Unfortunately, I cannot alter the URLs, so I am hoping this will help me handle the situation.

Also, does this rule actually go in the .ini file? If so, do I need to comment out all the other rules already in there?

Thanks in advance, and I apologize for my ignorance.
Apr 11, 2007 at 9:03 PM
Edited Apr 13, 2007 at 7:40 PM
Hey Frank!
Yes, IIRF can do what you want.
To figure out the proper rules, what you want to do is use the testDriver.exe program.
Check the IIRF distribution. Inside the README, there is information on the testdriver and how to use it.

Essentially, you drop in your expected "input" urls in a file called SampleUrls.txt, and you specify your rewrite rules in the ini file, and run the testdriver. The testdriver then pumps each sample url through the rules and shows you what would result. it is a quick, fast easy way to do iterative testing of your rules against expected URLs.

Once you have that all sorted, you drop your rule set into the IsapiRewrite.ini file for the actual filter.
Apr 13, 2007 at 5:51 PM
I can't get it to work. I created a folder in the /tests/ folder called Frank and placed the testdriver.exe, the .ini file, the samples file, and the .dll in it. In my .ini file I put:

^*/view?docid=(.+) /includes/redirect.aspx?docid=$1

In my sample file I put:


I open a DOS window, execute the testdriver command, and it just keeps repeating this line that says something like, ........AwaitWatcherTermination()........ It ran all night. I looked towards the top of the DOS window and where it referenced the line in my sampels file it just says, "No Rewrite."

Any ideas?
Apr 13, 2007 at 7:36 PM
Edited Apr 13, 2007 at 7:46 PM
Hey Frank, the syntax for the ini file is something like this:

 RewriteRule  ^.*/view\?docid=(.+) /includes/redirect.aspx?docid=$1 

  1. Specify REWRTIERULE as the first text on the line, for a rule.
  2. Escape the question mark in the URL. Question marks are significant in the regular expression language.
  3. Use a . before the * in the rule.

This worked for me. Check the readme for more details and tons of examples.

If you want you could do regular-expression-based validation of the docid, for example using the text (\d+) to capture the docid instead of (.+). The former says, "capture a string of one of more digits". The latter says "capture a string of one or more characters of any type". But maybe you don't want to validate. it's up to you.

Apr 13, 2007 at 8:00 PM
OK, I will try everything else I mentioned sounds correct?
Apr 13, 2007 at 8:38 PM
It appears that the TestDriver worked, but when I put that rule in the .ini file for my application and go to a page that matches the criteria...nada.

Again, I have the .ini and .dll files in the /bin/ directory. The filter is running in IIS. Maybe my rule is wrong. The entire URLs that I want to capture are like:

Apr 13, 2007 at 8:44 PM

Thanks a bunch!