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
link|improve this question
You mean the other way around? From search... to index.php?...? – Qtax Jun 9 '11 at 11:54
from index to search – fxuser Jun 9 '11 at 12:01
feedback

migrated from stackoverflow.com Jun 9 '11 at 12:53

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

Try this:

RewriteCond %{QUERY_STRING}  ^query=(.*)$
RewriteRule ^search/? index.php?action=search&query=%1 [QSA,L]
link|improve this answer
it still does show up the $_GET["query"] – fxuser Jun 9 '11 at 12:02
ok this seems to work but my other rewrotes affected it... thanks – fxuser 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. – fxuser Jun 9 '11 at 16:15
feedback

You need to capture it into a capturing group.

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

Your Answer

 
or
required, but never shown

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