主要网址www.url.com至www.url.com/en/我使用以下控制器
public function rootAction(Request $request) {
$locale = $request -> getLocale();
return $this -> redirect($this -> generateUrl('dbe_underConstructionLang', array('_locale' => $locale)));
}
这里的路线: 默认值:
dbe_underConstruction:
path: /
defaults: { _controller: DbeBundle:UnderConstruction:root }
这是默认页面
dbe_aboutus:
path: /{_locale}/aboutus
defaults: { _controller: DbeBundleBundle:Aboutus:index }
requirements:
_locale: en|fr|de
此外,我无法使登录路由多语言,因为在security.yml中,我无法设置所需的_locale参数:
dbe_login:
path: /login
defaults: { _controller: DbeBundle:Login:login}
firewalls:
secured_area:
pattern: ^/
form_login:
check_path: /login_check
login_path: /login
logout:
path: /logout
target: /
谢谢!