Is it possible to create a wildcard match using the Zend Framework Zend_Controller_Router_Route_Hostname for the actual domain? I tried the simple example below but the system would not recognize the route. When I hardwired the route (login.domain.com), it would work properly.
是否可以使用Zend Framework Zend_Controller_Router_Route_Hostname为实际域创建通配符匹配?我尝试了下面的简单示例,但系统无法识别路线。当我硬连线路线(login.domain.com)时,它会正常工作。
resources.router.routes.login.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.login.route = "login.*"
resources.router.routes.login.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.login.chains.index.route = ":action/*"
resources.router.routes.login.chains.index.defaults.controller = "login"
resources.router.routes.login.chains.index.defaults.action = "index"
2 个解决方案
#1
2
$route = new Zend_Controller_Router_Route_Hostname ('login.:domain.:net');
$_SERVER ['HTTP_HOST'] = 'login.example.com';
$request = new Zend_Controller_Request_Http ();
$match = $route->match ($request);
var_dump($match);
#2
1
Is this possible without the :domain.:net both being explicit, i.e. without stipulating just one period?
这可能没有:域。:net都是明确的,即没有规定只有一个时期?
i.e. I currently have
即我现在有
new Zend_Controller_Router_Route_Hostname('sub.example.com',array('controller' => 'x'));
new Zend_Controller_Router_Route_Hostname('sub.example.com',array('controller'=>'x'));
..but what I'd really like to do is:
..但我真正想做的是:
new Zend_Controller_Router_Route_Hostname('sub.:remainder',array('controller' => 'x'));
new Zend_Controller_Router_Route_Hostname('sub.:remainder',array('controller'=>'x'));
..whereby this route will match any hostname that begins with 'sub.' including sub.example.com, sub.another.example.com, sub.somethingelse.com, sub.com etc.
..此路由将匹配任何以'sub'开头的主机名。包括sub.example.com,sub.another.example.com,sub.somethingelse.com,sub.com等。
Doesn't seem to work though!
虽然似乎不起作用!
Anyone got this working?
有人这个有用吗?
#1
2
$route = new Zend_Controller_Router_Route_Hostname ('login.:domain.:net');
$_SERVER ['HTTP_HOST'] = 'login.example.com';
$request = new Zend_Controller_Request_Http ();
$match = $route->match ($request);
var_dump($match);
#2
1
Is this possible without the :domain.:net both being explicit, i.e. without stipulating just one period?
这可能没有:域。:net都是明确的,即没有规定只有一个时期?
i.e. I currently have
即我现在有
new Zend_Controller_Router_Route_Hostname('sub.example.com',array('controller' => 'x'));
new Zend_Controller_Router_Route_Hostname('sub.example.com',array('controller'=>'x'));
..but what I'd really like to do is:
..但我真正想做的是:
new Zend_Controller_Router_Route_Hostname('sub.:remainder',array('controller' => 'x'));
new Zend_Controller_Router_Route_Hostname('sub.:remainder',array('controller'=>'x'));
..whereby this route will match any hostname that begins with 'sub.' including sub.example.com, sub.another.example.com, sub.somethingelse.com, sub.com etc.
..此路由将匹配任何以'sub'开头的主机名。包括sub.example.com,sub.another.example.com,sub.somethingelse.com,sub.com等。
Doesn't seem to work though!
虽然似乎不起作用!
Anyone got this working?
有人这个有用吗?