阿帕奇发送的.js文件不正确的响应头 [英] Apache sending incorrect response header for .js files

查看:191
本文介绍了阿帕奇发送的.js文件不正确的响应头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,Chrome正在报告错误的MIME类型.js文件。这些文件送达的Apache 2,这原本并没有提及它的conf文件js文件。

I noticed that Chrome is reporting the wrong MIME type for .js files. The files are served with Apache 2, which originally did not reference js files in its conf file.

我添加了以下配置的http.conf:

I added the following configuration to http.conf:

AddType application/x-javascript .js

然后重新加载的配置。 .js文件仍在与此响应头发送的:

Then reloaded the config. .js files are still being sent with this Response Header:

HTTP/1.1 200 OK
Date: Wed, 16 Jan 2013 16:39:42 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.4.10
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

有没有.htaccess文件。

There are no .htaccess files.

什么会导致Apache将发送一个不正确的内容类型,即使我指定的应用程序/ x-JavaScript中的配置并重新加载服务器?

What would cause Apache to send an incorrect Content-Type, even though I've specified application/x-javascript in the config and reloaded the server?

推荐答案

最近,我遇到了这个另一台服务器上,并解决了这个问题。 conf.d / php.conf 包含这些行:

I ran into this on another server recently and solved the problem. conf.d/php.conf contained these lines:

AddHandler php5-script .php .phtml .html .css .js
AddType text/html .php

我改变了第一行

AddHandler php5-script .php .phtml .html
AddType text/html .php

然后保存并重新启动Apache的。该JS&放大器; css文件,现在有出现在Firefox / Chrome中正确的MIME类型。

Then saved and restarted Apache. The js & css files now appear with the correct mime type in Firefox/Chrome.

顺便说一句我尝试添加将AddType文字/ JavaScript的.js文件略低于将AddType text / html的.PHP ,但文件仍然表现为的text / html 的督察。我不得不删除AddHandler的.css和.js文件要发送正确的MIME类型。

As an aside I tried adding AddType text/javascript .js just below AddType text/html .php, but the files still showed as text/html in Inspector. I had to remove .css and .js from AddHandler for the correct mime type to be sent.

这篇关于阿帕奇发送的.js文件不正确的响应头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆