Symfony2 Routing - route subdomains

后端 未结 6 981
半阙折子戏
半阙折子戏 2020-11-29 19:13

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

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 20:11

    Alternatively get hostname in the controller:

    class DefaultController extends PowmaController {
    
      /**
       * @Route("/test")
       */
      public function testAction() {
        return new Response( 'Hostname ' . $this->getRequestHostnameString() );
      }
    
      function getRequestHostnameString() {
        return $this->getRequest()->getHost();
      }
    

提交回复
热议问题