0

Why on earth does this not work when all my other URL rewrites work perfectly:

rewrite "^/search/?\?q(.+)$" /search.php?q$1 break;

I did restart nginx and all of that.

3
  • how do your urls look line? what's the expected result? Commented Mar 10, 2013 at 14:25
  • I'm trying to change search?q=whatever OR search/?q=whatever to search.php?q=whatever Commented Mar 10, 2013 at 14:30
  • this should work. what's you error? also, try with \1 instead of $1 as a replacement Commented Mar 10, 2013 at 14:35

1 Answer 1

2

Rewrite only works on uri path. You don't need to rewrite the query string part because by default it's automatically attached to the new url.

rewrite /search /search.php break;

For example, /search?q=something will be written to /search.php?q=something.

See http://wiki.nginx.org/HttpRewriteModule#rewrite for more detail. This line below addresses your question

Also rewrite operates only on path, not parameters.

Sign up to request clarification or add additional context in comments.

Comments

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.