Symfony2でホスト名ベースのルーティングを設定する方法はありますか?
公式ドキュメントでこのトピックについて何も見つかりませんでした。
http://symfony.com/doc/2.0/book/routing.html
指定されたホスト名に基づいてリクエストをルーティングしたい:
foo.example.com
bar.example.com
{{subdomain}}.example.com
したがって、本質的に、コントローラーはパラメーターとして渡された現在のサブドメインを取得します。
Zend ソリューションと同様:
http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.hostname
$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
':username.users.example.com',
array(
'controller' => 'profile',
'action' => 'userinfo'
)
);
$plainPathRoute = new Zend_Controller_Router_Route_Static('');
$router->addRoute('user', $hostnameRoute->chain($plainPathRoute));
それが可能であることを願っていますが、どういうわけかそれを逃しました。
前もって感謝します!