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
2
  • You mean the other way around? From search... to index.php?...? – Qtax Jun 9 '11 at 11:54
  • from index to search – stergosz Jun 9 '11 at 12:01
2

Try this:

RewriteCond %{QUERY_STRING}  ^query=(.*)$
RewriteRule ^search/? index.php?action=search&query=%1 [QSA,L]
4
  • it still does show up the $_GET["query"] – stergosz Jun 9 '11 at 12:02
  • ok this seems to work but my other rewrotes affected it... thanks – stergosz Jun 9 '11 at 14:12
  • Are you able to get it working? Or you still having issues? If you still having issues please share your all rewrite rules. – Hameedullah Khan Jun 9 '11 at 15:17
  • i placed it on top and before my other rewriterules so its working now. – stergosz Jun 9 '11 at 16:15
0

You need to capture it into a capturing group.

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

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.