Help configuring IsapiRewrite4.ini

Topics: User Forum
Apr 17, 2007 at 8:05 PM
I need help configuring my ini file.

All I want to do is redirect links as follows:
/Fkt-NOT USED-PID-ID.html -> /index.asp?funktion=Fkt&ParentID=PID&Kategorie=ID

/cars-bmw-0-3-373.html -> /index.asp?funktion=cars&ParentID=0-3&Kategorie=373
/cars-bmw-0-3-373-541.html -> /index.asp?funktion=cars&ParentID=0-3-373&Kategorie=541
/cars-bmw-0-3-373-541-954.html -> /index.asp?funktion=cars&ParentID=0-3-373-541&Kategorie=954

If the above can not be used, how should I then separate the PID and ID in my links to make it work?

All other links are not to be redirected, so that any link that dosen't fit the above rule should not be redirected.

Thanks for your help!
Apr 17, 2007 at 9:52 PM
Edited Apr 17, 2007 at 9:56 PM
Welcome to the forums...

I highly recommend downloading Expresso; a free RegEx builder, analyzer. Helps me out immensely when figuring out expressions.

On to your question.

It may be easier to separate your query string by "folder" such as:


It'd make things a bit easier to read and shorten any "filenames".

That being said:

The sticky part is your ParentID, which looks like it can grow to x number of levels.

I came up with this:
RewriteRule ^/([\w]+)/(?:[\w]+)/(.+)/([\d]+).html$ /index.asp?funktion=$1&ParentID=$3&Kategorie=$4

The $2 rule, "bmw" doesn't appear to be used in your query string; so I used a non-capture group.
If you wanted to revert to a long file name just change the internal "/" to "-".

The only part I don't like about my rule is the (.+), Since you're using only digits and dashes, it would be better to explicitly look for only digits and dashes but I couldn't come up with a simple expression to do so, so I took the cheap way out.

Try that out and see if that works!

PS. don't forget to use the TestDriver.exe app to check rule rewriting!
Apr 19, 2007 at 11:54 AM
Thanks for your repply. But I would really like to use links like:

The reason is to do with search results and advertisement. But how should the expression then look like or how should I separate my parentid from the id?
Apr 19, 2007 at 4:03 PM
You'd just modify the rule such as:

RewriteRule ^/([\w]+)-(?:[\w]+)-(.+)-([\d]+)\.html$ /index.asp?funktion=$1&ParentID=$3&Kategorie=$4

I also escaped the "." before the "hmtl"

I tested the expression in Expresso and it had no problems translating it and finding a match to your suggested URLS.

Give it a shot.