我有上zend_router_hostname“动态子域”的问题,我有这样的代码(我没有这样的,但whant使用子域名作为路线parametr子域):如何在Zend Framework中路由动态子域?
protected function _initRoutes() {
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$config = $this->getOptions();
Zend_Registry::set("config", $config);
$routerHost = new Zend_Controller_Router_Hostname(':language.mysite.local',
array('controller' => 'index',
'action' => 'index',
'language'=>'pl')
);
$router->addDefaultRoutes();
$routes = $router->getRoutes();
foreach ($routes as $key => $routeEntry) {
$router->addRoute($key, $routeHost->chain($routeEntry));
}
}
但是当我尝试做电如。 :pl.mysite.local我得到服务器未找到错误。 我的/ etc/hosts文件是:
127.0.0.1 localhost
127.0.2.1 mysite.local
127.0.3.1 mysite.dev
127.0.4.1 mysite.production
我的虚拟主机配置是:
VirtualHost *:80>
DocumentRoot "/var/www/mysite/public"
ServerName mysite.local
ServerAlias *.mysite.local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/var/www/mysite/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我试图用的dnsmasq与像条目:
address=/local/127.0.0.1
但问题仍然存在,我不知道如何解决这种情况,任何线索我做错了什么?
不要让你的应用程序复杂。首先在服务器配置中路由子域,然后在Zend Framework中执行标准路由。你的应用程序会说声谢谢你。 – hakre 2012-08-09 12:12:48