Dynamic Rewrite

I’m wondering if its possible to make a dynamic rewrite in HTACCESS.

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ list.php?q=$1 [QSA]

allows me to do list/florida/miami/red/small/helmet be returns it all under q=something/again/and/again/and/again

then i did this

RewriteRule ^list\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /list.php [L]

which does list/florida/miami/red/small/helmet which then i would take it out of the url and parse it.

i’m trying to do


Florida is State
Miami is City
Color is Red
Size is Small
Category is Helmet

ok so you’re thinking so just parse the url. ok ya… duh…

let’s say the person query is


if i parsed the url into an array and assumed [3] is Color: and it assigns color Helmet

I normally do this …
RewriteRule list/(.)/(.)/(.*)$ list.php?state=$1&city=$2&size=$3 etc…

but if i don’t have all three parameters in there i get page not found list/here/here/here

BTW (.*) is just quick example so i can post faster…

Am i thinking too deep into this?

You don’t do the break down in .htaccess, given the original rule.

You do it within PHP.

$_GET[‘q’] will be set to list/florida/miami/red/small/helmet.

So using explode(), you parse it out and do your thing.

Yeah, that’s what i figured. I ended up coding a URI mapper