Php Zend framework中指定的控制器(css)无效
我试图在Zend框架中应用css。我的css文件位于Php Zend framework中指定的控制器(css)无效,php,css,zend-framework,Php,Css,Zend Framework,我试图在Zend框架中应用css。我的css文件位于public/css/layout.css中。首先,我在bootstrap.php中添加了以下代码行: protected function _initPlaceholders() { $this->bootstrap('View'); $view = $this->getResource('View'); $view->doctype('XHTML1_STRICT'); // Set the in
public/css/layout.css
中。首先,我在bootstrap.php
中添加了以下代码行:
protected function _initPlaceholders()
{
$this->bootstrap('View');
$view = $this->getResource('View');
$view->doctype('XHTML1_STRICT');
// Set the initial title and separator:
$view->headTitle('My Site')
->setSeparator(' :: ');
// Set the initial stylesheet:
$view->headLink()->prependStylesheet('../../css/layout.css');
}
它只指定要使用的标题和样式表。然后在layout.phtml
中添加以下代码:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
echo $this->headTitle();
echo $this->headScript();
// add a link to the site style sheet
echo '';
echo $this->headLink();
?>
</head>
请帮助我解决此问题。试试看
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
这应该会有帮助。您的/public/.htaccess文件中是否有此代码 如果您没有前4行,该文件将把您对“css/layout.css”的请求重定向到index.php,然后Zend将其解释为控制器->操作的链接 如果您有此文件,请确保服务器上已启用mod_rewrite 你应该把你的链接放在“akond”说的地方 好运=)这对我有帮助: [更新] 好的,只是在我的.htaccess文件中添加了下面的一行,现在一切都正常了
重写规则!。(js | ico | txt | gif | jpg | png | css | htc | swf | htm)$index.php
但后来我发现了这个:
接受您前面问题的答案,您可能会得到一些帮助。htaccess文件包含上述行,并且服务器上启用了重写模块,正如httpd.conf中一样,我已经取消了LoadModule rewrite_modules modules/mod_rewrite.so行的注释,但仍然存在相同的问题。您可以通过直接链接访问css文件吗?例如:?或者它返回的内容与firebug报告的内容相同?
$view->headLink()->prependStylesheet('/css/layout.css');
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]