php - Permanent redirection with "sub-routes" -
i need change base of routing system in sf2 project.
i used frameworkbundle:redirect:urlredirect redirect permanently few routes, :
# file : app/config/routing.yml # .. redirect_route_example: pattern: /foo defaults: _controller: frameworkbundle:redirect:urlredirect path: / permanent: true # .. if have lot of subroutes "master route" /foo (like /foo/page1, /foo/page2, /foo/page1/subpage1, etc.)
is possible make same thing frameworkbundle:redirect:urlredirect regex route (like /foo/* -> /*)?
my thought add parameter right after /foo, /foo{subroutes} , allow slashes in parameter. need this:
http://symfony.com/doc/master/cookbook/routing/slash_in_parameter.html
the solution this:
# file : app/config/routing.yml # .. redirect_route_example: path: /foo{subroutes} requirements: subroutes: ".*" defaults: _controller: frameworkbundle:redirect:urlredirect path: / permanent: true # .. edit:
note solution redirects / starts /foo isn't behaviour want. if want keep subroute , rid of /foo @ beginning, use key route instead of path , controller frameworkbundle:redirect:redirect instead of urlredirect in defaults of redirect_routing_sample , use route parameter {subroutes}.
Comments
Post a Comment