IIS 7 Simple Regular Expression with Extra Values ​​1, 2, or 3

I am trying to make a regex with the following url:

www.mydomain.com/newyear/food/maincourse/

and rewrite? Default.aspx case = (NewYear) & type = (nutrition) & category = (maincourse)

It works great with:

([_0-9a-zA-Z]+)/([_0-9a-zA-Z-]+)/([_0-9a-zA-Z-]+)/$

but I would like it to work only with www.mydomain.com/newyear/food/ and just rewrite with the empty category . The only way to do it now is by n00bing and create 3 rewrite rules - one for each value.

I am sure there is a smarter way, and please let me know. :)

+3
source share
2

, :

([_0-9a-zA-Z]+)/?([_0-9a-zA-Z-]*)/?([_0-9a-zA-Z-]*)/?$
+3

", ", , URL- ( ).

([[:alpha:]]|[[:punct:]])+/?([[:alpha:]]|[[:punct:]])*/?([[:alpha:]]|[[:punct:]])*
+1

Source: https://habr.com/ru/post/1775679/


All Articles