über meine Sym, lassen fony Projekt wir an, wir folgende Route haben:Symfony alle Routen umleiten mit auf URL Endung
$route= new Route('/my-method',array(
'_controller'=>'AppBundle:MyController:myMethod'
));
$collection->add('my_method_route',$route);
$route= new Route('/my-method2',array(
'_controller'=>'AppBundle:MyController:myAnotherMethod'
));
$collection->add('my_method2_route',$route);
$route= new Route('/anotherStuff',array(
'_controller'=>'AppBundle:MyController:anotherStuff'
));
$collection->add('another_stuff',$route);
$route= new Route('/anotherStuff/{param}',array(
'_controller'=>'AppBundle:MyController:anotherStuffOneParam'
));
$collection->add('another_stuff',$route);
$route= new Route('/anotherStuff/{param}/{another_param}',array(
'_controller'=>'AppBundle:MyController:anotherStuffTwoParam'
));
$collection->add('another_stuff',$route);
Und ich will, wenn eine URL mit /
zB endet. http//example.com/my-method/
um in http//example.com/my-method
umzuleiten.
Also habe ich überlegt, ob ich Regex als ersten Parameter auf der Route verwenden kann oder um das Symfony-Routing-System showhow zu konfigurieren, um die Umleitung durchzuführen.
Aber kann Symfony eine Regex oder irgendwie einen optionalen Teil auf URL annehmen, dass es ingoned werden könnte? zB um '/my-method2/?'
zu verwenden, um zu sagen, dass die Route mit /
enden kann, und diese Dinge einfach ignorieren.
Sie können dies mit einem gewissen Konfiguration auf Web-Server-Ebene zu tun, auch: Sie gar nicht brauchen symfony. – DonCallisto