我需要运行基于zend_framework的同一站点才能在多个域上运行,我的应用程序需要知道它运行在哪个域上.我认为使用Zend_Controller_Router_Route_Hostname是个好主意,但我遇到了一些问题.
我的bootstrap中有以下代码
$ctrl = Zend_Controller_Front::getInstance();
$router = $ctrl->getRouter();
$router->removeDefaultRoutes();
$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
':sub-domain.:domain.:tld'
);
$defaultRoute = new Zend_Controller_Router_Route(
':controller/:action/*',
array(
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('default',$hostnameRoute->chain($defaultRoute));
Run Code Online (Sandbox Code Playgroud)
我收到以下错误"未指定子域".我想我在我的布局文件中跟踪它的$ this-> url是在路由与请求url匹配之前使用已定义的路由来汇编url.如果我将默认值设置为主机名路由,则不会收到错误,但布局中的URL使用默认值而不是当前主机名中的值.
谁能帮我解决这个问题?
我的网站使用zend框架并在子文件夹中运行,例如:http://www.example.com/sub/folder.现在我想在/ sub/folder /中添加我的css链接,以便在http://www.example.com/sub/folder/product/abc这样的页面中加载css ,我以为我找到了一个视图帮助器来执行此操作BaseUrl但BaseUrl似乎只能在实际的视图文件中工作,而不能在引导类中工作.有谁知道这个的原因和一个可以解决的解决方法?
这是我的boodstrap类的片段.
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initStylesheet()
{
$this->_logger->info('Bootstrap ' . __METHOD__);
$this->bootstrap('view');
$this->_view = $this->getResource('view');
$this->_view->headLink()->appendStylesheet($this->_view->baseUrl('/css/main.css'));
}
}
Run Code Online (Sandbox Code Playgroud)