Jonathan
Jonathan

Reputation: 43

.htaccess rewrite with parameters and directory

So i want to rewrite my urls, but I want to know if it is possible to do it, and if it a good idea (you know thinking about what is good practice and what is not).

Let's say I have the following:

example.com/electronics/tvs/?inches=54&make=sony

and I want to rewrite it so tvs is translated to a parameter i.e., category=tvs and also keep the other parameters inches=54&make=sony.

Right now I have the following:

RewriteRule ^electronics/([^\/]+)/?(.*) electronics.php?category=$1&$2  [NC,L]

But when I try to get the parameters using $_REQUEST I am only able to retrive the category parameter.

Upvotes: 1

Views: 84

Answers (1)

Jonathan Kuhn
Jonathan Kuhn

Reputation: 15301

Add the QSA flag to your flag list [NC, L, QSA]. That will forward any additional query string parameters on to your script. QSA = "Query String Append"

Upvotes: 1

Related Questions