【问题标题】:CSS file showing as "text/x-csrc", being read as text/html in browser and ignoredCSS 文件显示为“text/x-csrc”,在浏览器中被读取为 text/html 并被忽略
【发布时间】:2012-09-29 21:12:45
【问题描述】:

Traq 安装包中包含的多个 css 文件在服务器上显示 MIME 类型为“text/x-csrc”。这些文件被浏览器读取为 text/html 并被忽略。

其他虚拟主机站点的 CSS 文件显示为 text/css。

我尝试将“text/x-csrc”文件的内容复制并粘贴到文本编辑器中,然后在服务器上创建一个新文件并使用 vi 粘贴。结果相同。

这是可疑文件,install.css

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/*!
 * Traq Install
 * Copyright (c) 2009-2012 Traq.io
 * @license GNU General Public License v3 only
 */
body {
    font-family: Arial, Helvetica, sans-serif;
    background: #e9e9e9;
    color: #fff;
    margin: 30px; }

#wrapper {
    width: 580px;
    margin: 0 auto;
    border-radius: 5px;
    box-shadow: 0 0 25px 1px rgba(0, 0, 0, 0.4); }

header {
    background: #3478AA;
    padding: 10px;
    height: 20px;
    border-radius: 5px 5px 0 0; }
header h1 {
    font-weight: bold;
    float: left; }
header h2 {
    float: right;
    font-weight: bold; }

#page {
    background: #fff;
    color: #000;
    padding: 10px;
    border-radius: 5px;
    margin: -5px 0;
    z-index: 10;
    position: relative;
    font-size: 14px; }

code {
    font-family: "Courier New", Courier, monospace;
}

#licence, #config_code {
    width: 550px;
    height: 400px;
    overflow: scroll;
    margin: 0 auto;
    background: #F6F6F6;
    border: 1px solid #e4e4e4;
    padding: 4px;
    font-size: 12px;
    font-family: "Courier New", Courier, monospace; }
#config_code {
    height: 125px }

.tabular .group {
    margin: 0;
    padding: 5px 0;
    padding-left: 250px;
    clear: left; }
.tabular label {
    font-weight: bold;
    float: left;
    margin-left: -250px;
    text-align: right;
    width: 245px;
    font-size: 12px;
    padding-top: 3px; }
.tabular input {
    margin-top: 0px;
    vertical-align: middle; }
.tabular select {
    margin-top: 0; }

.actions {
    text-align: center;
    margin-top: 5px; }

.error label {
    color: red; }
.error input {
    border: 1px solid red;
    padding: 2px; }

footer {
    font-size: 11px;
    padding: 6px;
    padding-top: 10px;
    background: #d9d9d9;
    color: #000;
    border-radius: 0 0 5px 5px; }

此文件中的哪些内容可能会触发错误的 MIME 类型?

编辑:

install.css 中的前两个字符是/* - 评论的开始标记。显然,我的 Apache 魔术文件将其解释为“C Source”而不是 CSS。

在默认 install.css 文件的开头添加一行返回将 MIME 类型从 C Source 更改为 CSS。

Chrome/Firefox 仍将文件错误地识别为 text/html。我已将此添加到 httpd.conf:

AddType text/css .css

仍然没有骰子。 Firefox 和 Chrome 都错误地将其读取为 text/html。

帮助?

【问题讨论】:

    标签: css mime-types


    【解决方案1】:

    您是从外部数据库中读取的还是什么?我猜你错过了打开和关闭样式的标签。

    【讨论】:

    • 这是 Traq 安装程序中包含的文件。它包含在
    • 另外,另一个文件 (nbs.css) 以相同的方式包含在内。两个文件中只有文本。包含的样式表中不需要打开/关闭标签。
    • 我不知道它在导入时带有标签,无需投票。
    • 答案表明 .css 文件(本质上是包含在内的)需要样式标签。我会给你一些懈怠,但对于较少的解释,我的答案被否决了。没有人让我松懈。
    • 它说我无法撤消反对票。也许这就是为什么没有人让我松懈,他们不能!不要冒犯,这不是个人的!
    猜你喜欢
    • 1970-01-01
    • 2016-01-07
    • 1970-01-01
    • 2020-05-23
    • 2011-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多