我在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