drs
drs

Reputation: 1255

mod_rewrite advice

I was wondering if you could advise if there is a more efficient way of writing what I have below? Could this be achieved in the 1 rule?

RewriteRule ^search/(cars|boats|plant)/([-a-zA-Z0-9]+)/type-([0-9]+)/price-([0-9]+)-([0-9]+)/?$ search.php?category=$1&location=$2&type=$3&minprice=$4&maxprice=$5 [L]
RewriteRule ^search/(cars|boats|plant)/([-a-zA-Z0-9]+)/type-([0-9]+)/?$ search.php?category=$1&location=$2&type=$3 [L]
RewriteRule ^search/(cars|boats|plant)/([-a-zA-Z0-9]+)/?$ search.php?category=$1&location=$2 [L]
RewriteRule ^search/(cars|boats|plant)/?$ search.php?category=$1 [L]

Also, I am having difficulty obtaining a friendly URL after a form is submitted. How to do this?

Upvotes: 0

Views: 60

Answers (1)

Amber
Amber

Reputation: 526483

Perhaps you'd be better off just writing one rule to redirect from /search to search.php, and then parsing the rest of the URI there? (I.e. redirect to search.php?q=REST_OF_URI_GOES_HERE)

Upvotes: 1

Related Questions