Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

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

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

    
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

2 Answers 2

up vote 1 down vote accepted

Try this:

RewriteCond %{QUERY_STRING}  ^query=(.*)$
RewriteRule ^search/? index.php?action=search&query=%1 [QSA,L]
share|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

You need to capture it into a capturing group.

RewriteRule ^search\?query=(.*)$ index.php?action=search&query=$1 [QSA,L]
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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