I want to handle dynamic subdomain in my Symfony 4 application.
I'm looking for configuration like this:
- store1.domain.com => StoreController::index
- store2.domain.com => StoreController::index
- www.domain.com => HomeController::homePage
- domain.com => HomeController::homePage etc etc.
I'm trying this code but is not working. Its always match with HomeController. StoreController never matching.
And when I try this configuration "domain.com" request show to me "Welcome to nginx!" page.
class StoreController extends AbstractController
{
/**
* @Route("/", name="store_home", host="{store_name}.domain.test")
*/
public function storeHomepage()
{
return $this->render('store/index.html.twig');
}
}
class HomeController extends AbstractController
{
/**
* @Route("/", name="site_home")
*/
public function homePage()
{
return $this->render('site/home/index.html.twig');
}
}
And here is my nginx configuration:
server {
listen 80;
server_name *.domain.test;
root /site/root/public;
location config bla bla bla;
}

所有评论(0)