Zend框架:获得航线子参数 [英] Zend Framework: get subdomain parameter from route

查看:101
本文介绍了Zend框架:获得航线子参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UPD:
解决了。问题是因为我们使用的nginx作为前端。所以nginx的不HTTP_HOST的传递给了Apache。

UPD: Solved. The problem was because we're using nginx as a frontend. So nginx doesn't pass the HTTP_HOST to apache.

您好!

我有一个生产服务器上获得的子域的参数在我的基地控制器,而在本地主机这是确定一个问题。从控制器一样网址等参数,操作返回,因为他们应该。

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.

这将返回null生产:

this returns null on production:

$agencyName = (string) $this->_getParam('agency');

没有进行更改为.htaccess:

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:

在引导路由器

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再次得到了同样的问题。

and yes, I do have $config['siteUri'] defined and i also tried using :agency.domain.com getting the same problem again

推荐答案

解决。问题是因为我们使用的nginx作为前端。所以nginx的不HTTP_HOST的传递给了Apache。

Solved. The problem was because we're using nginx as a frontend. So nginx doesn't pass the HTTP_HOST to apache.

这篇关于Zend框架:获得航线子参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆