Hi guys...

I d need some help on this one...
Basically i would like to make to transform the following:

site.com/category/sub/?q3=var1&q4=var2etc to

but some twists:
- ending slash is optional (site.com/one, or site.com/one/ shld give the same result)

- directories are optional too
site.com?q3=varetc => site.com/index.php?q3=varetc
site.com/one => site.com/index.php?q1=one
site.com/one?q3=varetc => site.com/index.php?q1=one&q3=varetc

I hope this makes sense...
anyway... whatever i tried just resulted in 500 errors. And no where to find a full solution searching Google.

If anyone could be kind enough...