I have a frindly(not so much but fits me well) URL expression on my HTACCESS. The page treats accordly with "mode" and ids
For editing a category:
#URL
edit.php?mode=cat&cat=1
#The expression
RewriteRule ^editar/([^/]*)/([^/]*)$ /edit.php?mode=$1&cat=$2 [NC,L]
#Output
/editar/cat/1
Editing subcategory:
#URL
edit.php?mode=subcat&cat=1&subcat=1
#The expression
RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&cat=$2&subcat=$3 [NC,L]
#Output
/editar/subcat/1/1
Editing product:
#URL
edit.php?mode=prod&cat=1&subcat=1&prod=1
#The expression
RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&cat=$2&subcat=$3&prod=$4 [NC,L]
#Output
/editar/prod/1/1/1
So far, so good!
But I have three expressions for the same page.
RewriteRule ^editar/([^/]*)/([^/]*)$ /edit.php?mode=$1&cat=$2 [NC,L]
RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&cat=$2&subcat=$3 [NC,L]
RewriteRule ^editar/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /edit.php?mode=$1&cat=$2&subcat=$3&prod=$4 [NC,L]
Is there any way to reduce that to just ONE expression, where some varible might be or might no be present on the string?
Like: edit.php?mode=prod&cat=1 THIS -> &subcat=1 AND THIS -> &prod=1 being optional?
Thanks!