0

我在Bootstrap.php中为我的全局布局初始化占位符,如此所述。

public function _initPlaceholders()
{
    $this->bootstrap('View');
    $view = $this->getResource('View');

    $view->doctype('XHTML11');

    $view->headTitle('Foo Bar Title')
         ->setSeparator(' :: ');

    $view->headMeta()->appendHttpEquiv(
        'content-type',
        'application/xhtml+xml; charset=UTF-8'
    );

    $view->headMeta()->appendName('robots', 'index,follow');

    $view->headLink()->appendStylesheet('/styles/styles.css', 'screen')
                     ->appendStylesheet('/styles/print.css', 'print');
}

呈现的 HTML 看起来是正确的。

<title>Foo Bar Title</title>
<link href="/styles/styles.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/styles/print.css" media="print" rel="stylesheet" type="text/css" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="robots" content="index,follow" />

但是 CSS 没有正确加载,因为 Zend_Controller 认为它是一个控制器或其他东西。当我尝试打开 CSS 文件时,会出现以下错误:

致命错误:未捕获的异常“Zend_Controller_Dispatcher_Exception”和消息“指定的控制器无效(错误)”

有什么提示吗?

[更新]

好的,只需将以下行添加到我的 .htaccess 文件中,现在一切都按预期工作......

RewriteRule !.(js|ico|txt|gif|jpg|png|css|htc|swf|htm)$ index.php

4

1 回答 1

0

一个典型的 Zend 项目布局如下所示:

.
|-- application
|   |-- Bootstrap.php
|   |-- configs
|   |-- controllers
|   |-- forms
|   |-- layouts
|   |-- models
|   `-- views
|-- library
`-- public
    |-- images
    |   `-- favicon.ico
    |-- index.php
    |-- js
    |   `-- scripts.js
    `-- styles
        `-- style.css

你的看起来像吗?具体来说,公共文件夹(而不是应用程序文件夹)下是否有 CSS 和 JavaScript 文件?如果是这样,您可以查看文件权限吗?

另外,我建议查看文件权限。如果 Apache 进程无法读取 CSS 文件,则 Apache 将无法为它们提供服务。

于 2011-06-14T16:01:30.540 回答