Symfony2路由-exclude.html
我想用Symfony2中的一个点来停止路线。例如: /博客/开发(这很好)Symfony2路由-exclude.html,symfony,routing,Symfony,Routing,我想用Symfony2中的一个点来停止路线。例如: /博客/开发(这很好) /blog/developm.ent(需要404) /blog/development.html(需要404) 如何使用yml实现这一点?这是我在上面第一个例子中得到的: s_nerds_blog_category_page: pattern: /blog/{category} defaults: { _controller: SNerdsBlogBundle:Default:category } sy
/blog/developm.ent(需要404)
/blog/development.html(需要404)
如何使用yml实现这一点?这是我在上面第一个例子中得到的:
s_nerds_blog_category_page:
pattern: /blog/{category}
defaults: { _controller: SNerdsBlogBundle:Default:category }
symfony2中的路线要求:
# matches only routes not containing a dot
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: ^[^\.]*$
您可以添加regex,请求的url需要匹配该正则表达式才能解析为特定路由:
# This example allows only digits (\d+) for {category}
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: \d+
排除包含点的路线:
# matches only routes not containing a dot
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: ^[^\.]*$
说明:
^
-字符串的开头[^\.]*
-除
以外的任何字符,任何重复次数$
-字符串结尾symfony2中的路线要求:
# matches only routes not containing a dot
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: ^[^\.]*$
您可以添加regex,请求的url需要匹配该正则表达式才能解析为特定路由:
# This example allows only digits (\d+) for {category}
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: \d+
排除包含点的路线:
# matches only routes not containing a dot
blog:
path: /blog/{category}
defaults: { _controller: AcmeBlogBundle:Blog:index, category: 1 }
requirements:
category: ^[^\.]*$
说明:
^
-字符串的开头[^\.]*
-除
以外的任何字符,任何重复次数$
-字符串结尾