Halfpint
Halfpint

Reputation: 4079

mod_rewrite get remaining query string parameters without matching them in the pattern

I am extremely new to RewriteRules so I am not sure if this is possible, is there any way of having my second query string parameter be passed to my RewriteRule without me having to specify it in the RegEx pattern?

The reason I ask is because I would like my URL to display as

http://mysite/Pumps/PumpID01

Opposed to

http://mysite.com/pumps/product.php?id=PumpID&s=Category

The current rewrite rule I am using is:

RewriteRule ^Pumps/([A-Za-z0-9_-]+)/?$ pumps/product.php?id=$1&s= [NC,L,QSA] 

If I specify 's' in the substituion then the page renders correctly. However 's' can be one of an expanding total of categories.

How would I go about passing the value of 's' dynamically?

Upvotes: 1

Views: 155

Answers (1)

anubhava
anubhava

Reputation: 785186

I would suggest you to have category identifier in the pretty URL as:

 http://mysite/Pumps/INTERMITTENT/PumpID01

If you agree then this rewrite rule should work:

 RewriteRule ^Pumps/([\w-]+)/([\w-]+)/?$ pumps/product.php?id=$2&s=$1 [NC,L,QSA]

Upvotes: 1

Related Questions