We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

nginx setting problem

I have a problem about nginx setting, like this :

    server {
        listen       80;
        server_name  localhost default_server;
        root         /usr/share/nginx/html;
        include /etc/nginx/default.d/*.conf;

        location /search {
        rewrite ^/search$ /search/;
        rewrite ^/search/(.*)$ /search/public/$1 break;
        try_files $uri $uri/ /search/public/index.php?_url=/$1;
        }

        error_page  404              /404.html;
        location = /40x.html {
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        }
    }

controller like this :

    /**
     * @RoutePrefix("/api")
     */
    class ApiController extends ControllerBase
    {
        /**
         * @Get("/q/{token}/{keyword}")
         */
        public function indexAction($token, $keyword)
        {
                echo $this->request->getQuery("something");
                echo $token;
                echo $keyword;
                exit();
        }
    }

I go to https://myip/search/profile/update/TOKEN/KEYWORD, it will go to profile controller and update action and print TOKEN and KEYWORD, but the problem is, when I useing $this->request->getQuery("something"), I cannot get that. wahat is the problem about the nginx setting?



1.3k

you need to add router in this case, so that token and keyword could recognize as params