I have an .htaccess rewrite rule like this:

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^search/(.*)$ search.php?q=$1

What this does is, if someone visits http://example.com/search/test the URI that is really processed is http://www.example.com/search.php?q=test.

Now, if I try to pass an extra random GET parameter to my rewritten URL, the parameter is ignored. So if I try to do visit here:


The parameter extra is ignored. It doesn't seem to get passed at all.

Can this problem be fixed? If so, how?


You are looking for the Query String Append flag - e.g.

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^search/(.*)$ search.php?q=$1 [QSA]

See the mod_rewrite documentation for a full description of RewriteRule flags.

  • Ah nice! I knew there was something like that. I'm a .htaccess noob. Dec 9 '11 at 22:09
  • Is there a way to add QSA to all rules
    – hakkikonu
    Sep 23 '14 at 7:57
  • Hi @danlefree Know it's an old question, but using Wamp, when i do this, all my stylesheets, scripts etc lose reference. how can I solve that?
    – Danny22
    Nov 4 '15 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.