Is there a way to set up hostname based routing in Symfony2?
I didn\'t find anything about this topic in the official documentation.
http://sy
This is my solution:
In the config.yml inside app dir add the following lines:
services:
kernel.listener.subdomain_listener:
class: Acme\DemoBundle\Listener\SubdomainListener
tags:
- { name: kernel.event_listener, event: kernel.request, method: onDomainParse }
Then create the class SubdomainListener.php as:
getRequest();
$session = $request->getSession();
// todo: parsing subdomain to detect country
$session->set('subdomain', $request->getHost());
}
}