在Symfony 2中设置索引路由 [英] Setting index route in Symfony 2

查看:154
本文介绍了在Symfony 2中设置索引路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Symfony2,并且是一个主要工作的网站,唯一的问题是我不知道如何设置默认路由。目前,我使用以下网址访问我的索引和其他路线:

I've got Symfony2 installed, and a mostly working site, the only issue is I don't know how to set a default route. Currently, I access my index and other routes with the following URLs:


www.example.com/app_dev.php/index

www.example.com/app_dev.php/index

www.example.com/app_dev.php/example_route

www.example.com/app_dev.php/example_route

我想要要将www.example.com默认为索引路由,因此我可以使用以下网址获得相同的结果:

I'd like to have www.example.com default to the index route, so I can get the same results with the following URLs:


www.example .com

www.example.com

www.example.com/example_route

www.example.com/example_route

我是运行lighttpd作为我的Web服务器。如何配置lighttpd / Symfony2来执行此操作?

I'm running lighttpd as my web server. How can I configure lighttpd/Symfony2 to do this?

推荐答案

只需创建一个映射到的路由/ 模式:

Just create a route that maps to the / pattern :

# app/config/routing.yml
homepage:
    pattern:   /
    defaults:  { _controller: AcmeHomeBundle:home:show }

这将路由到您指定的任何控制器。

This will route to whatever controller you specify.

这篇关于在Symfony 2中设置索引路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆