에로 끝나는 모든 경로를 리디렉션, fony 프로젝트는 우리가 다음과 같은 경로를 가정하자 :심포니 내 Sym을지나 URL
$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);
그리고 URL이 /
예로 끝나는 때 나는 원한다. http//example.com/my-method/
을 http//example.com/my-method
으로 리디렉션하십시오.
경로에서 첫 번째 매개 변수로 regex를 사용하거나 리디렉션을 수행하기 위해 Symfony의 라우팅 시스템 showhow를 구성 할 수 있다면 생각했습니다.
하지만 Symfony는 정규식을 사용하거나 URL에 선택적으로 삽입 할 수 있습니까? 예를 들어 '/my-method2/?'
을 사용하여 경로가 /
으로 끝나고 theese 항목을 무시한다는 것을 알리십시오.
당신은 심지어 일부 구성 웹 서버 수준에서이 작업을 수행 할 수 있습니다 전혀 심포니 필요하지 않습니다는. – DonCallisto