remove extra slashes for one route

Hove remove extra slashes only for one route? All others actions work with slash on the end. I need remove slash only for on route.

$router->add("/media/:action/([0-9]+)X([0-9]+)/:params", array( 'controller' => 'media', 'action' => 1, 'width' => 2, 'height' => 3, 'path' => 4 ))->setName("proxy");

Hi @moledet,

unfortenately this is not possible at the moment(see more this code line: As you can see there, removing extra slashes is a behaivior either applied for all matching rotes or none.

Only way making it work is by overwriting handle method in Router service, so the route could handle specific conditions regarding extra slashes and specific routes.

I hope this answer is going to be helpful!


Can you give an example? Is the slash after param?

I have some routes defined twice, once with a slash and once without. For a small number of routes, this is not a problem. For a large number of routes, the routing code slowed down and I looked at alternative approaches.

There are ways to pre process and post process the routes. Before routing, you might add the slash for the route that does not use the slash then, after routing, ignore the slash.

You can add $router->removeExtraSlashes(true); where you define your router


it's will remove from all routers(rules)

You can add $router->removeExtraSlashes(true); where you define your router