How are you doing? I'm developing a multilingual platform with Symfony2. If someone types in www.url.com/project I want to have it redirected to www.url.com/en/project. Whats the easiest way to do so without repeating a method and all the routes a couple of times?
For the main url www.url.com to www.url.com/en/ I use the following controller
public function rootAction(Request $request) {
$locale = $request -> getLocale();
return $this -> redirect($this -> generateUrl('dbe_underConstructionLang', array('_locale' => $locale)));
}
And here the routes: The default:
dbe_underConstruction:
path: /
defaults: { _controller: DbeBundle:UnderConstruction:root }
This is a default page
dbe_aboutus:
path: /{_locale}/aboutus
defaults: { _controller: DbeBundleBundle:Aboutus:index }
requirements:
_locale: en|fr|de
Furthermore I was not able to make the login route multilingual because in the security.yml I was not able to set the required _locale parameter:
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: /
Thanks already!