.htaccess rewrite pretty urls that get variables can use

I am trying to write a .htaccess line that will be rewritten in php script, but still allow the addition of additional incremental variables at the end. Is it possible?

I am currently trying to use this:

RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L] 

The goal is to be able to do things like blah.com/item/foo , but also blah.com/item/foo?bar=whatever .

Currently, it seems to correctly pass the first part, id , but not the rest.

+6
source share
2 answers
 RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L,QSA] 

Here you can learn more about QSA (query string append): https://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

+13
source

You need to finish using [L,QSA]

+5
source

All Articles