我们有一些需要登录才能访问的文件,并且如果用户使用文件的URL或HTML资源的URL进入应用程序,我想在认证后重定向到不同的页面。 我有一个URL:
https://subdomain.domain.com/resource/45/identifiers/567/here/11abdf51e3d7-some%20file%20name.png/download
。我想获取这个URL的路由名称。 运行app/console router:debug
命令会输出以下内容:_route_name GET ANY subdomain.domain.{tld} /resource/{id2}/identifiers/{id2}/here/{id3}/download
。Symfony有一个Routing组件(http://symfony.com/doc/current/book/routing.html),我试图在Symfony IOC提供的Symfony\Bundle\FrameworkBundle\Routing\Router
实例上调用match()
方法来匹配该URL与路由。我尝试过带有域名和不带域名的方式,但它们都会创建一个MethodNotAllowed
异常,因为找不到路由。如何将此URL与路由匹配?