【发布时间】:2010-09-15 18:13:07
【问题描述】:
我目前有一个运行 Apache 的内部网站。它提供一些 cgi 脚本网页(perl 代码)。最近在 Firefox 和 Chrome 中,它开始显示 HTML 代码的纯文本版本。在 Internet Explorer 中,它将 cgi 文件呈现为 HTML,但在 Chrome 和 Firefox 中,它呈现为纯文本。
在 perl 代码中,我有以下内容:
#!/usr/bin/perl --
#
#Prints the HTML MIME TYPE FOR WEB BROWSERS.
print "content-type: text/html\n\n";
print <<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Statistics</title>
--- OUTPUT SNIPPED ---
HTML
使用 Firefox 的应用程序,我看到响应标头是 text/plain 而不是 text/html。
我不确定它是否可能是 Apache 配置,或者内容类型是否缺少某些内容。
【问题讨论】:
-
header一般大写,即
Content-Type: text/html -
您提到这发生在“最近”,您还记得在这之前您所做的更改吗?
-
网站代码是通过subversion签入的,最近一次修改大概是两周前。
-
我尝试将 Content-Type 大写,但没有帮助。还尝试了 content-type: text/html; charset=utf-8 也没有运气。
标签: html apache firefox google-chrome cgi