Symfony2路径之间的区别
Symfony2 difference between path
我必须使用我的 Symfony2 项目设置一个记住我的登录并且我必须在 security.yml
中设置我的防火墙
我做了类似的事情
remember_me:
secret: '%secret%'
lifetime: 604800
path: ^/
我想知道路径参数 / 和 ^/ 有什么区别?
假设您的 url 是这个:https://example.com/
^/
<=> 捕获所有以“/”开头的路径
/
<=> 捕获所有以“/”开头的路径
所以在这种情况下没有区别,两者都匹配 https://example.com/
的最后一个“/”之后的所有路径
在你的情况下,你必须用“/”代替“^/”,因为“^/”在这种情况下没有意义。
根据 doc :
path (default value: /)
The path where the cookie associated with this
feature is used. By default the cookie will be applied to the entire
website but you can restrict to a specific section (e.g. /forum,
/admin).
看看documentation。相关段落引用:
Prepending the path with ^ means that only URLs beginning with the
pattern are matched. For example, a path of simply /admin (without the
^) would match /admin/foo but would also match URLs like /foo/admin.
我必须使用我的 Symfony2 项目设置一个记住我的登录并且我必须在 security.yml
中设置我的防火墙我做了类似的事情
remember_me:
secret: '%secret%'
lifetime: 604800
path: ^/
我想知道路径参数 / 和 ^/ 有什么区别?
假设您的 url 是这个:https://example.com/
^/
<=> 捕获所有以“/”开头的路径
/
<=> 捕获所有以“/”开头的路径
所以在这种情况下没有区别,两者都匹配 https://example.com/
的最后一个“/”之后的所有路径在你的情况下,你必须用“/”代替“^/”,因为“^/”在这种情况下没有意义。
根据 doc :
path (default value: /)
The path where the cookie associated with this feature is used. By default the cookie will be applied to the entire website but you can restrict to a specific section (e.g. /forum, /admin).
看看documentation。相关段落引用:
Prepending the path with ^ means that only URLs beginning with the pattern are matched. For example, a path of simply /admin (without the ^) would match /admin/foo but would also match URLs like /foo/admin.