to display query in the url?

I have simple search method in my posts controller.
When I enter some keyword, it shows results at ...posts/search URL.
How can I make it display something like ..posts/search?query=this ?