Trailing slash on end url

In the router I have set the URL as follows.

$routes->connect(‘/page-test/’, [‘controller’ => ‘Test’, ‘action’ => ‘display’]);

If I call a url without a slash at the end, the URL works as well. I need to disable this rule so that URLs work only with a slash at the end, as defined in the router. In debug mode, the routing tab - you can see that all rules are without a slash at the end. Please, give me an advice.

I have routes like this:

$routes->connect('/dog/index', ['controller' => 'Dogs', 'action' => 'index']);

And no problems. Clear any cache after making changes.

I forget if cake caches routes, if so clear that cache as well.

As I wrote, I need a slash at the end. If I clear the cache, the problem is the same, routing variables are still without a slash at the end. Is it possible to set what I have written in the router so that it respects the rules?

May not work: /page-test
Must work: /page-test/

First, if your route has parameters, the docs explain how to use parameters:
https://book.cakephp.org/4/en/development/routing.html#passing-parameters-to-action

The example I gave has no parameters, so why would you need an extra slash.

Example just a url (no) parameters https://cakephp.org

With parameters https://book.cakephp.org/3/en/development/configuration.html

I need all URLs to end with a slash. Is there any way to do it?

Take look: https://stackoverflow.com/questions/11829714/add-trailing-slash-htaccess

And a solution without 301 redirects?

Have you tried stackoverflow for your redirect question.

I haven’t tried because it is a 301 redirect. I need the router to work as I define it. The page /page-test/ works, but if I have a paginator, the links in it refer to /page-test?page=2, etc., how do I make a slash in the paginator? Without slashing my paging doesn’t work.

And why not see a slash in the debug router when I have it in my code?

	$routes->connect('/page-test/', ['prefix' => 'Pages', 'controller' => 'Test', 'action' => 'display']);