Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have an .htaccess rewrite rule like this:

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

What this does is, if someone visits http://www.mysite.com/search/test the URI that is really processed is http://www.mysite.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?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

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.

share|improve this answer
Ah nice! I knew there was something like that. I'm a .htaccess noob. –  Jakobud Dec 9 '11 at 22:09
Is there a way to add QSA to all rules –  hakkikonu Sep 23 '14 at 7:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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