UPD: Solved. The problem was because we're using nginx as a frontend. So nginx doesn't pass the HTTP_HOST to apache.
Hi there!
I'm having a problem with getting subdomain parameter in my base controller on a production server while on the localhost it's ok. other parameters from url like controller, action returned as they should.
this returns null on production:
$agencyName = (string) $this->_getParam('agency');
no changes made to .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]
and here's my vhost settings:
<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>
Does anybody knows why it happenes?
upd:
routers in Bootstrap
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();
}
and yes, I do have $config['siteUri'] defined and i also tried using :agency.domain.com getting the same problem again
Use the following :
If you provide a valid subdomain (ie. only consisting of characters a-z0-9), it will be passed in agency, if not then agency will not be set. (At least it works for me using ZF 1.11.3 :p).
Solved. The problem was because we're using nginx as a frontend. So nginx doesn't pass the HTTP_HOST to apache.