Apache question mark RewriteRule question

apache-2.2mod-rewriteregex

So i am trying to redirect from

index.php?action=search&query=search text goes here

to

search?query=search text goes here

i tried this so far but with no luck

RewriteRule ^search/? index.php?action=search&query=$1 [QSA,L]

EDIT : Solution was

RewriteCond %{QUERY_STRING}  ^query=(.*)$
RewriteRule ^search/? index.php?action=search&query=%1 [QSA,L]

and since i had some other RewriteRules in my htaccess i had to put them above them.

my other rewriterules were like this:

RewriteRule ^(\w+)/?$ index.php?action=$1

Best Answer

Try this:

RewriteCond %{QUERY_STRING}  ^query=(.*)$
RewriteRule ^search/? index.php?action=search&query=%1 [QSA,L]