【发布时间】:2011-07-15 12:22:36
【问题描述】:
首先,我想说我对编程很陌生,所以如果我没有尽快跟进,请原谅我。
现在,最近几天我遇到了一个困扰我的问题,我到处寻找解决方案。
我正在使用 WAMP 服务器配置。在我开始使用 CSS 之前,一切都运行良好。我有一个外部 CSS 文件。
当我在 Dreamweaver 中查看我的 HTML 页面时,我发现它已正确连接到该 CSS 文件。我可以在设计视图中看到正在应用的样式。但是,当我在浏览器中查看页面时,Firefox 说(在错误控制台中)无法加载 .css 文件,因为它的 MIME 类型是 text/html 而不是 text/css。
所以我认为这是服务器配置问题。我所做的是以下内容: 我进入 .HTACCESS 文件并添加了以下行: AddType text/css .css
重新启动我的服务器后,这仍然没有解决问题。出于某种原因,浏览器一直将我的 css 文件作为 html 文件读取。知道这里可能出了什么问题吗?
这是我试图在浏览器中加载的文件的头部(它实际上是一个 Smarty 模板):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../htdocs/css/styles.css" type="text/css" media="all" />
</head>
另外,请注意我正在使用 Zend 框架进行编码。 这是我的 .HTACCESS 文件:
重写引擎开启
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
重写规则 ^(.*)$ index.php/$1
AddType text/css .css
所以我听取了 DA 的建议,在浏览器中查看页面时点击了查看页面源,然后点击了指向我的 CSS 文件的链接。这就是它向我展示的内容:
当我点击链接时,我看到:
<br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in C:\shaancode\www\phpweb20\htdocs\Zend\Controller\Dispatcher\Standard.php on line <i>248</i></th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Zend_Controller_Dispatcher_Exception: Invalid controller specified (error) in C:\shaancode\www\phpweb20\htdocs\Zend\Controller\Dispatcher\Standard.php on line <i>248</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0006</td><td bgcolor='#eeeeec' align='right'>382488</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\shaancode\www\phpweb20\htdocs\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0892</td><td bgcolor='#eeeeec' align='right'>4748936</td><td bgcolor='#eeeeec'>Zend_Controller_Front->dispatch( )</td><td title='C:\shaancode\www\phpweb20\htdocs\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>42</td></tr>
</table></font>
【问题讨论】:
-
你的 css 文件的文件名是什么,当你查看浏览器时,你链接样式表标签是什么意思?
-
嘿,Shaan,我们需要查看头部的 HTML 来弄清楚发生了什么。一旦您发布了该内容,我们就会对发生的事情有更多的了解。
-
你的 CSS 文件的内容是什么样的?
-
在 Firefox 中从您的服务器打开您的页面。去查看源代码。在源文件中,单击 CSS 文件的 URL。什么负载?我的猜测是您的 CSS 文件链接没有链接到文件,因此您的服务器将其作为自定义错误页面提供服务。该页面将是 HTML,因此会出现错误。
-
我粘贴了我点击该链接时看到的内容。我在这里看到某种错误,但不确定我是否理解发生了什么?哦,看起来这是 Zend 显示错误时的样式。嗯。为什么会这样显示?
标签: css configuration mime-types mime