djt
djt

Reputation: 7535

mod_rewrite - Rule question

For dynamic pages, I have all requests going to product.php page, and sorting through the params. The rules are:

RewriteRule ^products/([^/]+)/([^/]+)/([^/]+)$ product.php?cat_slug=$1&sub_slug=$2&product_slug=$3 [L,QSA]
RewriteRule ^products/([^/]+)/([^/]+)$ product.php?cat_slug=$1&sub_slug=$2 [L,QSA]
RewriteRule ^products/([^/]+)$ product.php?cat_slug=$1 [L,QSA]

I now want a rule to handle ALL other requests to go to page.php?id=$1. Something like:

([^/]+) page.php?id=$1

Unfortunately that doesn't work. Any ideas?

Upvotes: 1

Views: 52

Answers (1)

Gumbo
Gumbo

Reputation: 655219

You need to specify the begin and end of the string and exclude the substitution paths:

RewriteCond $1 !^(page|product)\.php$
RewriteRule ^([^/]+)$ page.php?id=$1

Upvotes: 2

Related Questions