Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Route based on query string


I would like to make a route for to another controller than index. I've tried this, but is not working

        'controller'    => 'page',
        'action'        => 'search'

edited Sep '17

Afaik routes only operate on the path component of the URI

You can handle it with dispatching:

class IndexController extends \Phalcon\Mvc\Controller {
    public function indexAction()
        if($this->request->hasQuery('s') && $this->request->hasQuery('searchfor')) {
              'controller' => 'page',
              'action' => 'search'
edited Sep '17

Query parameters are part of $_GET in php. Use request->hasQuery

Thanks Lajos. Worth to remember your solution. I've made a 301 redirect from htaccess in the end, because my main concern was the old searches indexed in google.