2

Using htaccess, I want to redirect

index.php?page=search&action=go&string=John+Doe

to

search.php?string=John+Doe

but only if page=search and action=go in the first url (string varies)

Any help appreciated, thank you.

1
  • Please note that SO is not a free coding service! You are expected to attempt yourself and only ask for assistance with your own code when you point out a specific issue you cannot solve. Commented Mar 7, 2017 at 16:27

1 Answer 1

3

Use below rule,

RewriteCond %{QUERY_STRING} ^page=search&action=go&string=(.+?)$
RewriteRule ^ /search.php?string=%1 [R=301,L]
Sign up to request clarification or add additional context in comments.

2 Comments

And if the query string comes with additional arguments or a different order of arguments?
1. Additional arguments: RewriteCond %{QUERY_STRING} ^page=search&action=go&string=(.+?)&(.+?)$ 2. Arguments are the same, but order varies. Apply RewriteCond in sequence: RewriteCond %{QUERY_STRING} ^page=search$ RewriteCond %{QUERY_STRING} ^action=go$ RewriteRule # here comes the rule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.