optional parameter/value pair

How can I define a route to catch by index controller the urls like:

  1. /par1/val1/par2/val2
  2. /par2/val2/par1/val1
  3. /par1/val1
  4. /par2/val2

With legacy urls they would look like :

  1. ?par1=val1&par2=val2
  2. ?par2=val2&par1=val1
  3. ?par1=val1
  4. ?par2=val2

1 and 2 are definitelly the same... How can I achieve this behavior with user-friendly urls?

Thanks