简体   繁体   中英

ZF2 subdomain routing with variable point's in subdomain

I need to setup a route for my ZF2 application with a variable point in it.

eg, I need to route subdomains like;

john.van.der.berg.domain.tld
nick.van.eisselsain.domain.tld
james.morris.domain.tld

I know the point's in the subdomain will always 1, 2 or 3

I now have to follow setup for my route but I can't figure out how to do it with the points?

 'username' => array(
                'type'    => 'hostname',
                'options' => array(
                    'route'    => ':username.domain.localhost',
                    'constraints' => array(
                            'action'  => 'username',
                            'username' => '[a-zA-Z0-9.]{1,3}*',
                    ),
                    'defaults' => array(
                        '__NAMESPACE__' => 'Users\Controller',
                        'controller'    => 'Users',
                        'action'        => 'website',
                    ),
                ),
            ),

Thanks in advance!

从ZF 2.1.3开始,您显示的代码应该可以正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM