user3132858
user3132858

Reputation: 667

.htaccess RewriteRule regex match specific words

I need an advice from someone which is a better expert in rewrite rules and regex expressions than me.

I have the following rewrite rule:

RewriteRule ^([^/]*)/$ /product.php?prod=$1 [L]

It basically rewrites any page between the slashes to product.php

www.website.com/prod1/
www.website.com/prod2/
www.website.com/apple/
www.website.com/orange/

However, I would like to only rewrite specific pages like:

www.website.com/apple/
www.website.com/orange/

How can I do this?

Upvotes: 2

Views: 2242

Answers (1)

Mark Shevchenko
Mark Shevchenko

Reputation: 8197

It may help:

RewriteRule ^(apple|orange)/$ /product.php?prod=$1 [L]

Upvotes: 3

Related Questions