Witam,

tak jak w temacie potrzebuje napisać router aby przekierowywał mnie na konkretny moduł. Chodzi, że jak wbijam na test.domen.pl to uruchamia mi się moduł test.

W obecnej chwili mam napisane coś takiego w application/bootstrap.php

  1. public function _initRoute() {
  2.  
  3. $this->bootstrap('frontcontroller');
  4. $frontController = $this->getResource('frontcontroller');
  5. $router = $frontController->getRouter();
  6.  
  7. $router->removeDefaultRoutes();
  8. $router->addRoute(
  9. 'langmodcontrolleraction', new Zend_Controller_Router_Route('/:lang/:module/:controller/:action/*')
  10. );
  11.  
  12. $router->addRoute(
  13. 'langmodulecontroller', new Zend_Controller_Router_Route(
  14. '/:lang/:module/:controller', array('lang' => 'pl', 'module' => 'module', 'controller' => 'index')
  15. )
  16. );
  17.  
  18. $router->addRoute(
  19. 'langmodule', new Zend_Controller_Router_Route(
  20. '/:lang/:module', array('lang' => 'pl', 'module' => 'module',)
  21. )
  22. );
  23.  
  24. $hostnameRoute = new Zend_Controller_Router_Route_Hostname(
  25. ':module.domain.com:.lang', array('lang' => 'pl','module' => 'konkurs'
  26. )
  27. );
  28. $normalRoute = new Zend_Controller_Router_Route(
  29. '/:lang/:controller/:action/*', array('lang' => 'pl','controller' => 'index','action' => 'index'
  30. )
  31. );
  32. $router->addRoute('default', $hostnameRoute->chain($normalRoute));
  33.  
  34. $router->addConfig(new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini'), 'routes');
  35. }


Próbowałem jeszcze zrobić coś takiego ale to też nie działa.

config/routers.ini
  1. resources.router.routes.subdomain.type = "Zend_Controller_Router_Route_Hostname"
  2. resources.router.routes.subdomain.route = ":test.example.com"
  3. resources.router.routes.subdomain.defaults.module = "test"
  4. resources.router.routes.subdomain.chains.index.type = "Zend_Controller_Router_Route"
  5. resources.router.routes.subdomain.chains.index.route = "/:lang/:controller/:action/*"
  6. resources.router.routes.subdomain.chains.index.defaults.controller = "index"
  7. resources.router.routes.subdomain.chains.index.defaults.action = "index"


No i to nie działa. Bo dostaje cały czas 500 :/ Proszę o pomoc.

dodam jeszcze żeby nie było, że jestem debilem ale zmieniłem vhosty na lokalu tak jak być powinno. I hosty działają tylko nie ładuje zawartości modułu.


Dobra wszystko działa. Jak by ktoś kiedyś potrzebował rozwiązania to podaje. W moim przypadku to pomoglo
  1. $hostnameRoute = new Zend_Controller_Router_Route_Hostname(
  2. ':test.hybryda.com', array('module' => 'test', 'controller' => 'index', 'action' => 'index')
  3. );
  4.  
  5. $plainPathRoute = new Zend_Controller_Router_Route_Static('');
  6.  
  7. $router->addRoute('test', $hostnameRoute->chain($plainPathRoute));