简体   繁体   English

在RHEL / Apache上返回.json文件的application / json内容类型

[英]Returning application/json content-type for .json files on RHEL/Apache

OS is specifically RHEL6 running Apache2. OS是专门运行Apache2的RHEL6。

So in my Apache configuration, I have: 所以在我的Apache配置中,我有:

LoadModule mime_module modules/mod_mime.so

And in /etc/mime.types , I have the following: /etc/mime.types ,我有以下内容:

application/json                                json

Yet when requesting a file with the .json extension (and containing valid JSON), the content-type is set to text/html . 但是,当请求具有.json扩展名(并包含有效JSON)的文件时,content-type设置为text/html Any idea how I can force the correct header for this file type? 知道如何强制这个文件类型的正确标头?

Use the AddType directive in the apache configuration: 在apache配置中使用AddType指令:

AddType application/json .json AddType application / json .json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM