Mobile app version of vmapp.org
Login or Join
Bethany197

: How to pass GET parameters to rewritten URL? I have an .htaccess rewrite rule like this: RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^search/(.*)$ search.php?q=

@Bethany197

Posted in: #Apache #Htaccess #ModRewrite #Php

I have an .htaccess rewrite rule like this:

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


What this does is, if someone visits example.com/search/test the URI that is really processed is 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:
www.example.com/search/whatever?extra=true
The parameter extra is ignored. It doesn't seem to get passed at all.

Can this problem be fixed? If so, how?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Bethany197

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cody1181609

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

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


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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme