Combining multiple htaccess rewrite rules into one

satsumo

New Member
First, let me say this: I suck at regex and htaccess. I'm trying to make a rule that will properly parse url segments into variables. So far I have this:\[code\]RewriteRule ^([^/]+)/?$ index.php?query[]=$1 [QSA,L]RewriteRule ^([^/]+)/([^/]+)/?$ index.php?query[]=$1&query[]=$2 [QSA,L]RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?query[]=$1&query[]=$2&query[]=$3 [QSA,L]RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?query[]=$1&query[]=$2&query[]=$3&query[]=$4 [QSA,L]\[/code\]It works, sort of, but I feel it's longer than it needs to be; and what if I want 5 or 6 or 7 variables? Is there a more condensed way to write this out?Also, when I spit out the query array, the first element is always index.php. What's up with that?
 
Back
Top