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?
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.