我对 zend_router_hostname 上的“动态子域”有疑问,我有类似的代码(我没有这样的子域,但不想使用子域作为路由参数):
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 时,我得到 Server not found 错误。我的 /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
但是问题仍然存在,我不知道如何解决这种情况,任何线索我做错了什么?