0

Can I link virtual host to specific module in zf2 ? I want my virtual host dev-api.mydomain.com to point to dev-api.mydomain.com/index.php/api directly. I've tried also with .htaccess with no chance.

Any suggestions?

Edit

this worked for me Zend Framework 2 Routing subdomains to module

Community
  • 1
  • 1
Muhammad Shaker
  • 163
  • 3
  • 14
  • You could experiment with routes. \Zend\Mvc\Router\Http\Hostname meaby this article will help little http://briangallagher.ie/2013/01/29/hostname-subdomain-routing-and-urls-using-zf2/ – Skaza Aug 06 '14 at 07:17
  • 2
    possible duplicate of [Zend Framework 2 Routing subdomains to module](http://stackoverflow.com/questions/13070824/zend-framework-2-routing-subdomains-to-module) – blackbishop Aug 06 '14 at 10:31

1 Answers1

0

If you are using ZF2 then any how you need to point /public/ in your virtual host confg. so let be there that virtual confg and here is your solution:if you want api module to come directly on the domain name(by default).zf2/confg/application.confg>>

'modules' => array(
    'Application',//default module
    'APi',//your module

),
'module_listener_options' => array(
    'module_paths' => array(
        './module',
        './vendor'
    ),
    'config_glob_paths' => array(
        'config/autoload/{,*.}{global,local}.php'
    )
)

then go to application/confg/module.config.php:

'router' => array(
    'routes' => array(
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Api\Controller\Index',//**your changes goes here**
                    'action'     => 'index',
                ),
            ),
        ),

        'application' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/application',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\Controller',
                    'controller'    => 'Index',
                    'action'        => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route'    => '/[:controller[/:action]]',
                        'constraints' => array(
                            'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),
                        'defaults' => array(
                        ),
                    ),
                ),
            ),
        ),
    ),
),
Jangya satapathy
  • 866
  • 8
  • 20