Custom pagination URL give 404


I want to do a small search engine on my Cakephp 4 application. I have a URL like this :
But generating the url for page 2 which is like this gives me a 404 error
My router is like this :

$builder->connect('/search/{query}',['controller' => 'Search', 'action' => 'index']);

where is my mistake ? is there a configuration problem somewhere ?

Thanks for any help

I’m not sure how your route should be configured to solve the problem. But I know what is going wrong if you haven’t yet zeroed in on that.

The index step of the url is getting dropped. This does not happen with other actions in the url and it only causes problems for index when you have query arguments. If you know how to set your configuration so that part is always included in the output url string your problem would be solved.


I seem to have a block regarding route configs and I’ve never sat down to study and get over it so I can’t provide a concrete fix.