0

I have a route, something like:

            array(
            'type'    => 'Hostname',
            'options' => array(
                'route'    => ':subdomain.:domain.:tld',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\Controller',
                    'controller'    => 'Index',
                    'action'        => 'index',
                ),
            )

What I would like to do is get the domain.tld as one single parameter, because I want to constrain the domain to a list, such as 'application1.com', 'example.org' etc.

I've tried

        array(
            'type'    => 'Hostname',
            'options' => array(
                'route'    => ':subdomain.:domain',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\Controller',
                    'controller'    => 'Index',
                    'action'        => 'index',
            ),

Is it possible to handle the domain and tld as a single router param?

Fatmuemoo
  • 2,187
  • 3
  • 17
  • 34

1 Answers1

2

I don't think you can do that with that particular router, but you can:

1) extend/create a new router to act as you want

2) Move this restriction outside of the codebase.

3) Using events to check the domain on bootstrap/dispatch and do taken appropriate action

I would recommend to perform this kind of restriction at a lower level (via apache/web server maybe) rather than in your code. If you want to put it in the code this is probably not the best place to put it.

Andrew
  • 12,617
  • 1
  • 34
  • 48
  • I ended up using option #2 b/c in my specific case I wanted the configuration to be dynamic based on the sub-domain. – Fatmuemoo Feb 13 '13 at 23:28