Reputation: 374
I'm doing some url rewrite with htaccess. I have this:
RewriteRule ^mesas$ http://www.myweb.net/piezas.php?pos=1 [L]
RewriteRule ^sillas$ http://www.myweb.net/piezas.php?pos=2 [L]
RewriteRule ^taburetes$ http://www.myweb.net/piezas.php?pos=3 [L]
This is working. If I write the url http://www.myweb.net/mesas I get http://www.myweb.net/piezas.php?pos=1.
Now I want to add other parameters. Example: I have this http://www.myweb.net/mesas?pag=10 and I want this: http://www.myweb.net/piezas.php?pos=1&pag=10
I'm try with:
RewriteRule ^mesas?(.*)$ http://www.myweb.net/piezas.php?pos=1&$1 [L]
and
RewriteRule ^mesas$?(.*) http://www.myweb.net/piezas.php?pos=1&$1 [L]
But it doesn't work. What am I doing wrong?
Thanks!
Upvotes: 0
Views: 1128
Reputation: 11799
Try adding flag QSA, like this:
RewriteRule ^mesas$ http://www.myweb.net/piezas.php?pos=1 [L,QSA]
RewriteRule ^sillas$ http://www.myweb.net/piezas.php?pos=2 [L,QSA]
RewriteRule ^taburetes$ http://www.myweb.net/piezas.php?pos=3 [L,QSA]
It will append the incoming query string to the existing one.
Upvotes: 2