3

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
stergosz
  • 129
  • 2
  • 7

2 Answers2

2

Try this:

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

You need to capture it into a capturing group.

RewriteRule ^search\?query=(.*)$ index.php?action=search&query=$1 [QSA,L]
alex
  • 141
  • 2
  • 7
  • i am trying to retrieve the $_GET["query"] but it doesnt seem to show up... so it seems its not working – stergosz Jun 09 '11 at 11:50