Recursive rewrite

Aug 18, 2008 at 5:35 PM

I've read document and I am almost sure this can be done with conditions, but I don't know how to start. I'd like this:

http://www.domain.com/recipe/5000 -> http://www.domain.com/recipe.asp?ID=5000
http://www.domain.com/recipe/5000/blahblah/ -> http://www.domain.com/recipe.asp?ID=5000
http://www.domain.com/recipe/5000/blahblah/blahblah2/ -> http://www.domain.com/recipe.asp?ID=5000

RewriteRule ^/recipe/(\d+)/[^/]*/[^/]*/([^/]*) /recipe.asp?id=$1&$2
RewriteRule ^/recipe/(\d+)/[^/]*/([^/]*) /recipe.asp?id=$1&$2
RewriteRule ^/recipe/(\d+)/([^/]*) /recipe.asp?id=$1&$2

etc....

but there must be simpler way to do it? And my "recursion" doesn't work with the first line where there is no / at the end :-(

Any help would be appreciated.

Jerry

Coordinator
Aug 21, 2008 at 12:46 PM

Jerry,
I suggest you start by fiddling with the testdriver - it is a good tool to quickly test out various rules and whether they work on various URL requests. You can specify incoming URLs, your desired outcome, and then run the testdriver and it will tell you if your rules do what you want them to do. Try out different things and you can iteratively develop the rules so they work just the way you want them.

Also see the examples on http://www.codeplex.com/IIRF/Wiki/View.aspx?title=Examples&referringTitle=Home