[英]Symfony 3 routing annotation set homepage
Right now my homepage is the DefaultController
: 现在我的主页是
DefaultController
:
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
But I'd like the default to be in my blog controller: 但我希望默认设置在我的博客控制器中:
/**
* @Route("/blog/index", name="blog_index")
*/
public function indexAction() {
I realise I could just set this route to /
, but what I'd like is for both /blog/index
and /
to route to the same action (displaying the /blog/index
url if possible). 我知道我可以将此路由设置为
/
,但是我想将/blog/index
和/
都路由到相同的操作(如果可能,显示/blog/index
网址)。
I've had a look for previous answers, but I can't find one that deals specifically with annotations. 我已经看过以前的答案,但找不到适合注释的答案。
Right now I'm just redirecting from the DefaultController
but that feels slightly hacky - does anyone have a better solution? 现在,我只是从
DefaultController
重定向,但感觉有点不客气-有没有人有更好的解决方案?
Have you tried the following in your blog controller? 您是否在博客控制器中尝试了以下方法?
/**
* @Route("/", name="homepage")
* @Route("/blog/index", name="blog_index")
*/
public function indexAction() { ... }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.