Htaccess rewriting rule depending on variable amount

Hello,

I’m trying to change /a/b/c to /index.php?a=1&b=2&c=3

I’ve got the rule in my htaccess file:

RewriteRule ([^/]+)/([^/]+)/? /index2.php?main=$1&category=$2 [QSA]

But I can’t figure out how to make this rule flexible to various amount of variables.

So
/a should rewrite to /index.php?a=1
/a/b should rewrite to /index.php?a=1&b=2
/a/b/c should rewrite to /index.php?a=1&b=2&c=3

hlep :slight_smile: