UPD: 已解决。问题是因为我们使用nginx作为前端。所以nginx不会将HTTP_HOST传递给apache。Zend Framework:从路由获取子域参数
你好!
我在生产服务器上的本地控制器上获取子域参数时出现问题,而本地主机没问题。来自URL的其他参数,如控制器,操作返回,因为他们应该。
返回null生产:
$agencyName = (string) $this->_getParam('agency');
作出的.htaccess没有变化:
RewriteEngine On
RewriteRule ^main - [L,NC]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这是我的虚拟主机设置:
<VirtualHost *:8080>
ServerName agencies.domain.com
ServerAlias *.agencies.domain.com
ErrorLog /var/log/apache2/agencies.domain_errors.log
DocumentRoot /var/www/agencies.domain.com/public/
<Directory "/var/www/agencies.domain.com/public">
Options -Indexes FollowSymLinks Includes
DirectoryIndex index.shtml index.php
AllowOverride All
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
有谁知道为什么一切发生的时候?
UPD:在引导
public function run()
{
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$plainPathRoute = new Zend_Controller_Router_Route(
':module/:controller/:action/*',
array(
'module' => 'default',
'controller' => 'index',
'action' => 'index',
)
);
$config = $this->getOptions();
$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
':agency.' . $config['siteUri'],
NULL,
array(
'agency' => '([a-z0-9]+)'
)
);
$router->addRoute('subdomain', $hostnameRoute->chain($plainPathRoute));
parent::run();
}
路由器,是的,我有$配置[ 'siteUri']定义的,我也尝试使用:agency.domain.com再次得到了同样的问题
好像我们需要检查您正在使用的路线。 – 2011-03-03 14:17:06
请创建答案,而不是回答答案中的问题。详细一点。 – markus 2011-03-04 08:34:54