我问我们是否要在文件中添加两条路线
因为我有这个错误:
No route found for "GET /blog"
感谢您的帮助
/app/config/routing.yml
rubens_blog:
resource: "@RubensBlogBundle/Resources/config/routing.yml"
prefix: /blog/
rubens_admin:
resource: "@RubensAdminBundle/Resources/config/routing.yml"
prefix: /admin/
/src/Rubens/Bundle/AdminBundle/Resources/config/routing.yml
post_homepage:
pattern: /
defaults: { _controller: RubensAdminBundle:Post:index }
post_archives:
pattern: /post/archives
defaults: { _controller: RubensAdminBundle:Post:archives }
post_show:
pattern: /post/show/{id}
defaults: { _controller: RubensAdminBundle:Post:show }
requirements:
id: \d+
/src/Rubens/Bundle/BlogBundle/Resources/config/routing.yml
post_homepage:
pattern: /
defaults: { _controller: RubensBlogBundle:Post:index }
post_archives:
pattern: /archives
defaults: { _controller: RubensBlogBundle:Post:archives }
答案 0 :(得分:1)
您错过了/
中的尾部斜杠/blog
。尝试在浏览器中打开下一页:
/blog/
或删除前缀:
rubens_blog:
resource: "@RubensBlogBundle/Resources/config/routing.yml"
prefix: /
并将路线更改为:
post_homepage:
pattern: /blog
defaults: { _controller: RubensAdminBundle:Post:index }
post_archives:
pattern: /blog/post/archives
defaults: { _controller: RubensAdminBundle:Post:archives }
post_show:
pattern: /blog/post/show/{id}
defaults: { _controller: RubensAdminBundle:Post:show }
requirements:
id: \d+
答案 1 :(得分:0)
您重新定义了路线名称。您的名字必须是唯一的:
rubens_blog:
resource: "@RubensBlogBundle/Resources/config/routing.yml"
prefix: /blog/
rubens_admin:
resource: "@RubensAdminBundle/Resources/config/routing.yml"
prefix: /admin/
/src/Rubens/Bundle/AdminBundle/Resources/config/routing.yml
admin_post_homepage:
pattern: /
defaults: { _controller: RubensAdminBundle:Post:index }
admin_post_archives:
pattern: /post/archives
defaults: { _controller: RubensAdminBundle:Post:archives }
admin_post_show:
pattern: /post/show/{id}
defaults: { _controller: RubensAdminBundle:Post:show }
requirements:
id: \d+
/src/Rubens/Bundle/BlogBundle/Resources/config/routing.yml
blog_post_homepage:
pattern: /
defaults: { _controller: RubensBlogBundle:Post:index }
blog_post_archives:
pattern: /archives
defaults: { _controller: RubensBlogBundle:Post:archives }